https://wiki.archlinux.org/api.php?action=feedcontributions&user=Andkore&feedformat=atomArchWiki - User contributions [en]2024-03-29T00:02:19ZUser contributionsMediaWiki 1.41.0https://wiki.archlinux.org/index.php?title=Postfix&diff=255460Postfix2013-04-28T04:39:24Z<p>Andkore: </p>
<hr />
<div>[[Category:Mail Server]]<br />
From [http://www.postfix.org/ Postfix's site]:<br />
:"''Postfix attempts to be fast, easy to administer, and secure, while at the same time being sendmail compatible enough to not upset existing users. Thus, the outside has a sendmail-ish flavor, but the inside is completely different.''"<br />
<br />
The goal of this article is to setup postfix for virtual mailbox delivery only. There will be no delivery to user accounts on the system ({{ic|/etc/passwd}}). Further, access will only be available via a web mail frontend (squirrelmail), no direct pop3 or imap access will be granted. It should be fairly easy to allow those additional features given the information below, but it is not within the scope of this document.<br />
<br />
==Required packages==<br />
*postfix<br />
*courier-imap<br />
*squirrelmail<br />
*mysql<br />
*apache<br />
*ssl<br />
<br />
If you have trouble finding a package specific to this How-To, try the resources link at the bottom.<br />
<br />
==Postfix Installation==<br />
===Step 1: Install Postfix===<br />
[[pacman|install]] package {{Pkg|postfix}} which can be found in the [[Official Repositories|official repositories]].<br />
<br />
===Step 2: Check /etc/passwd, /etc/group===<br />
Make sure that the following shows up in {{ic|/etc/passwd}}:<br />
postfix:x:73:73::/var/spool/postfix:/bin/false<br />
<br />
Make sure that the following shows up in {{ic|/etc/group}}:<br />
postdrop:x:75:<br />
postfix:x:73:<br />
<br />
{{Note|Postfix can be made to run in a chroot. This document does not currently cover this and might be added later.}}<br />
<br />
==Postfix Configuration==<br />
===Step 1: Setup MX record ===<br />
<br />
An MX record should point to the mail host. Usually this is done from configuration interface of your domain provider.<br />
<br />
A mail exchanger record (MX record) is a type of resource record in the Domain Name System that specifies a mail server responsible for accepting email messages on behalf of a recipient's domain. <br />
<br />
When an e-mail message is sent through the Internet, the sending mail transfer agent queries the Domain Name System for MX records of each recipient's domain name. This query returns a list of host names of mail exchange servers accepting incoming mail for that domain and their preferences. The sending agent then attempts to establish an SMTP connection to one of these servers, starting with the one with the smallest preference number, delivering the message to the first server with which a connection can be made. <br />
<br />
{{Note|Some mail servers will not deliver mail to you if your MX record points to a CNAME. For best results, always point an MX record to an A record definition. For more information, see e.g. [https://secure.wikimedia.org/wikipedia/en/wiki/List_of_DNS_record_types Wikipedia's List of DNS Record Types].}}<br />
<br />
===Step 2: /etc/postfix/master.cf===<br />
This is the Pipeline configuration file, in which you can put your new pipes e.g. to check for Spam!<br />
<br />
===Step 3: /etc/postfix/main.cf===<br />
<br />
==== For virtual mail====<br />
<br />
=====Step 3.1 myhostname=====<br />
set myhostname if your mail server has multiple domains, and you do not want the primary domain to be the mail host. The default is to use the result of a gethostname() call if nothing is specified.<br />
For our purposes we will just set it as follows:<br />
<pre><br />
myhostname = mail.nospam.net<br />
</pre><br />
This is assuming that a DNS A record, and an MX record both point to mail.nospam.net<br />
<br />
=====Step 3.2 mydomain=====<br />
this is usually the value of myhostname, minus the first part. If your domain is wonky, then just set it manually.<br />
<pre><br />
mydomain = nospam.net<br />
</pre><br />
<br />
=====Step 3.3 myorigin=====<br />
this is where the email will be seen as being sent from. I usually set this to the value of mydomain. For simple servers, this works fine. This is for mail originating from a local account. Since we are not doing local delivery (except sending), then this is not really as important as it normally would be.<br />
<pre><br />
myorigin = $mydomain<br />
</pre><br />
<br />
=====Step 3.4 mydestination=====<br />
This is the lookup for local users. Since we are not going to deliver internet mail for any local users, set this to localhost only.<br />
<pre><br />
mydestination = localhost<br />
</pre><br />
<br />
=====Step 3.5 mynetworks and mynetwork_style=====<br />
Both of these control relaying, and whom is allowed to. We do not want any relaying.<br />
For our sakes, we will simply set mynetwork_style to host, as we are trying to make a standalone postfix host, that people with use webmail on. No relaying, no other MTA's. Just webmail.<br />
<pre><br />
mynetworks_style = host<br />
</pre><br />
<br />
=====Step 3.6 relaydomains=====<br />
This controls the destinations that postfix will relay TO. The default value is $mydestination. This should be fine for now.<br />
<pre><br />
relay_domains = $mydestination<br />
</pre><br />
<br />
=====Step 3.7 home_mailbox=====<br />
This setting controls how mail is stored for the users.<br />
Set this to "Maildir/", as courier IMAP requires Maildir style mail storage. This is a good thing. Maildir format mailboxes remove the possible race conditions that can occur with old style mbox formats. No more need to deal with file locking. The '/' at the end is REQUIRED.<br />
<pre><br />
home_mailbox = Maildir/<br />
</pre><br />
<br />
=====Step 3.8 virtual_mail=====<br />
Virtual mail is mail that does not map to a user account (/etc/passwd). This is where all the email for the system will be kept. We are not doing local delivery, remember, so if you want a user that has the same name as a local user, just make a virtual account with the same name.<br />
First thing we need to do is add the following:<br />
<br />
virtual_mailbox_domains = virtualdomain.tld<br />
virtual_alias_maps = hash:/etc/postfix/virtual_alias, mysql:/etc/postfix/mysql_virtual_forwards.cf<br />
virtual_mailbox_domains = mysql:/etc/postfix/mysql_virtual_domains.cf<br />
virtual_mailbox_maps = mysql:/etc/postfix/mysql_virtual_mailboxes.cf<br />
virtual_mailbox_base = /home/vmailer<br />
virtual_uid_maps = static:5003<br />
virtual_gid_maps = static:5003<br />
virtual_minimum_uid = 5003<br />
virtual_mailbox_limit = 51200000<br />
<br />
virtual_mailbox_domains is a list of the domains that you want to receive mail for. This CANNOT be the same thing that is listed in mydestination. That is why we left mydestination to be localhost only.<br />
virtual_mailbox_maps will contain the info about the virtual users and their mailbox locations. We are using a hash file to store the more permanent maps, and these will override the forwards in the mysql database.<br />
<br />
virtual_mailbox_base is the base dir where the virtual mailboxes will be stored.<br />
The gid and uid maps are the real system user account that the virtual mail will be owned by. This is for storage purposes. Since we will be using a web interface, and do not want people accessing this by any other means, we will be creating this account later with no login access.<br />
Virtual_mailbox_limit controls the size of the mailbox. I do not know how well this works yet. I have set the size above to about 50MB.<br />
<br />
=====Step 3.9 Default message &amp; mailbox size limits=====<br />
<br />
Postfix imposes both message and mailbox size limits by default. The message_size_limit controls the maximum size in bytes of a message, including envelope information. (default 10240000) The mailbox_size_limit controls the maximum size of any local individual mailbox or maildir file. This limits the size of '''any''' file that is written to upon local delivery, '''including files written by external commands''' (i.e. procmail) that are executed by the local delivery agent. (default is 51200000, set to 0 for no limit) If bounced message notifications are generated, check the size of the local mailbox under /var/spool/mail and use postconf to check these size limits:<br />
<br />
supersff:~> postconf -d mailbox_size_limit<br />
mailbox_size_limit = 51200000<br />
supersff:~> postconf -d message_size_limit<br />
message_size_limit = 10240000<br />
<br />
==== Local Mail ====<br />
The only things you need to change in '''/etc/postfix/main.cf''' are as follows. Uncomment them and modify them to the specifics listed below. Everything else can be left as installed by pacman.<br />
<br />
inet_interfaces = loopback-only<br />
mynetworks_style = host<br />
append_dot_mydomain = no<br />
default_transport = error: Local delivery only!<br />
<br />
If you want to control where the mail gets delivered and which mailbox format is to be used, you can do this by setting <br />
home_mailbox = /some/path <br />
or <br />
mail_spool_directory some/path<br />
''mail_spool_directory'' is an absolute path where all mail goes, while ''home_mailbox'' specifies a mailbox relative to the user's home directory. If the path ends with a slash ('/'), messages are stored in Maildir format (directory tree, one message per file); if it doesn't, the mbox format is used (all mail in one file). <br />
<br />
Examples:<br />
mail_spool_directory = /var/mail (1)<br />
home_mailbox = Maildir/ (2)<br />
1) All mail will be stored in /var/mail, mbox format<br />
<br />
2) Mail will be saved in ~/Maildir, Maildir format<br />
<br />
===Step 4. /etc/postfix/aliases===<br />
We need to map some aliases to real accounts. The default setup by arch looks pretty good here. =D<br />
Uncomment the following line, and change it to a real account. I put the user account on the box that I use. Best not to just send mail to root, because you do not want to be logging in as root or checking email as root. Not good. Sudo is your friend, and so is forwarding root mail. Since this is for local delivery only (syslogs and stuff), it is still within the realm of mydestination.<br />
<br />
root: USER<br />
<br />
Once you have finished editing {{ic|/etc/postfix/aliases}} you must run the postalias command.<br />
<br />
postalias /etc/postfix/aliases<br />
<br />
===Step 5. /etc/postfix/virtual_alias===<br />
Create /etc/postfix/virtual_alias with the following contents<br />
<br />
{{hc|/etc/postfix/virtual_alias|<br />
MAILER-DAEMON: postmaster<br />
postmaster: root<br />
<br />
# General redirections for pseudo accounts<br />
bin: root<br />
daemon: root<br />
named: root<br />
nobody: root<br />
uucp: root<br />
www: root<br />
ftp-bugs: root<br />
postfix: root<br />
<br />
# Put your local aliases here.<br />
<br />
# Well-known aliases<br />
manager: root<br />
dumper: root<br />
operator: root<br />
abuse: postmaster<br />
<br />
# trap decode to catch security attacks<br />
decode: root<br />
<br />
# Person who should get root's mail. Don't receive mail as root!<br />
root: cactus@virtualdomain.tld<br />
}}<br />
<br />
Then run the postalias command on it.<br />
postalias /etc/postfix/virtual_alias<br />
<br />
Alternatively you can create the file .forward in /root. specify the user to whom root mail should be forwarded, e.g. ''user@localhost''.<br />
<br />
{{hc|/root/.forward|<br />
user@localhost<br />
}}<br />
<br />
===Step 6. mysql_virtual_domains.cf===<br />
Create the /etc/postfix/mysql_virtual_domains.cf file with the following (or similar) contents:<br />
<pre><br />
user = postfixuser<br />
password = XXXXXXXXXX<br />
hosts = localhost<br />
dbname = postfix<br />
table = domains<br />
select_field = 'virtual'<br />
where_field = domain<br />
</pre><br />
<br />
===Step 7. mysql_virtual_mailboxes.cf===<br />
Create the /etc/postfix/mysql_virtual_mailboxes.cf file with the following (or similar) contents:<br />
<pre><br />
user = postfixuser<br />
password = XXXXXXXXXX<br />
hosts = localhost<br />
dbname = postfix<br />
table = users<br />
select_field = concat(domain,'/',email,'/')<br />
where_field = email<br />
</pre><br />
Instead of having a directory structure something like ''/home/vmail/example.com/user@example.com'' you can have cleaner subdirectories (without the additional domain name) by replacing ''select_field'' and ''where_field'' with:<br />
<pre><br />
query = SELECT CONCAT(SUBSTRING_INDEX(email,'@',-1),'/',SUBSTRING_INDEX(email,'@',1),'/') FROM users WHERE email='%s'<br />
</pre><br />
<br />
===Step 8. mysql_virtual_forwards.cf===<br />
Create the /etc/postfix/mysql_virtual_forwards.cf file with the following (or similar) contents:<br />
<pre><br />
user = postfixuser<br />
password = XXXXXXXXXX<br />
hosts = localhost<br />
dbname = postfix<br />
table = forwardings<br />
select_field = destination<br />
where_field = source<br />
</pre><br />
<br />
===Step 9. postfix check===<br />
Run the {{ic|postfix check}} command. It should output anything that you might have done wrong in a config file. <br />
<br />
To see all of your configs, type {{ic|postconf}}. To see how you differ from the defaults, try {{ic|postconf -n}}.<br />
<br />
===Step 10. Enable and Start the Daemon===<br />
Enabling the service will automatically start postfix at boot, but needs to be started manually for the first time.<br />
<br />
# systemctl enable postfix.service<br />
# systemctl start postfix.service<br />
<br />
===Step 11. newuser===<br />
We need to create the user for storing the virtual mail. Create a vmailuser as follows:<br />
<pre><br />
groupadd -g 5003 vmail<br />
useradd -g vmail -u 5003 -d /home/vmailer -s /bin/false vmailer<br />
mkdir /home/vmailer<br />
chown vmailer.vmail /home/vmailer<br />
chmod -R 750 /home/vmailer<br />
passwd vmailer<br />
</pre><br />
note that 5003 is the gid specified in the postfix main.cf file.<br />
note that 5003 is the uid specified in the postfix main.cf file.<br />
<br />
==Mysql configuration==<br />
===Step 1. Create a mysql Database===<br />
Create mysql database called 'postfix', or something similar.<br />
<br />
CREATE DATABASE postfix;<br />
USE postfix;<br />
<br />
===Step 2. Setup table structure.===<br />
Import the following table structure.<br />
<pre><br />
CREATE TABLE `domains` (<br />
`domain` varchar(50) NOT NULL default '',<br />
PRIMARY KEY (`domain`),<br />
UNIQUE KEY `domain` (`domain`)<br />
);<br />
<br />
<br />
CREATE TABLE `forwardings` (<br />
`source` varchar(80) NOT NULL default '',<br />
`destination` text NOT NULL,<br />
PRIMARY KEY (`source`)<br />
);<br />
<br />
CREATE TABLE `users` (<br />
`email` varchar(80) NOT NULL default '',<br />
`password` varchar(20) NOT NULL default '',<br />
`quota` varchar(20) NOT NULL default '20971520',<br />
`domain` varchar(255) NOT NULL default '',<br />
UNIQUE KEY `email` (`email`)<br />
);<br />
</pre><br />
<br />
===Step 3. Create a mysql user===<br />
Add a user for postfix to use. Something like "postfixuser".<br />
Give permissions for postfix user to the table. This user should be listed in the /etc/postfix/mysql_virtual_domains.cf file.<br />
<br />
The [http://dev.mysql.com/doc/refman/5.5/en/server-administration.html official reference manual] has a detailed guide on user management and server administration in general.<br />
<br />
The following is just an example for creation of 'postfixuser' with password 'XXXXXXXXXX'.<br />
Note that the GRANT statements need to be executed after creating the tables in the next step.<br />
<br />
CREATE USER 'postfixuser' IDENTIFIED BY 'XXXXXXXXXX';<br />
GRANT SELECT, INSERT, UPDATE, DELETE ON domains TO postfixuser;<br />
GRANT SELECT, INSERT, UPDATE, DELETE ON forwardings TO postfixuser;<br />
GRANT SELECT, INSERT, UPDATE, DELETE ON users TO postfixuser;<br />
<br />
===Step 4. Add a domain.===<br />
<pre><br />
INSERT INTO `domains` VALUES ('virtualdomain.tld');<br />
</pre><br />
<br />
===Step 5. Add a user.===<br />
<pre><br />
INSERT INTO `users` VALUES ('cactus@virtualdomain.tld', 'secret', <br />
'20971520', 'virtualdomain.tld');<br />
</pre><br />
<br />
The above creates the user and sets a password as secret. <br />
<br />
This will allow you to use encrypted passwords<br />
<br />
<pre><br />
INSERT INTO `users` VALUES ('cactus@virtualdomain.tld', ENCRYPT('secret'), <br />
'20971520', 'virtualdomain.tld');<br />
</pre><br />
<br />
==Test Postfix==<br />
===Step 1: Start postfix===<br />
See [[Daemons#Starting_manually]]<br />
<br />
===Step 2: Test postfix===<br />
Lets see if postfix is going to deliver mail for our test user.<br />
{{bc|<br />
telnet servername 25<br />
ehlo testmail.org<br />
mail from:<test@testmail.org><br />
rcpt to:<cactus@virtualdomain.tld><br />
data<br />
This is a test email.<br />
<br />
.<br />
quit<br />
}}<br />
==== Error response ====<br />
451 4.3.0 <lisi@test.com>:Temporary lookup failure<br />
maybe you have entered the wrong user/pass for mysql or the mysql socket is not in the right place.<br />
<br />
<br />
==== See that you have received a email ====<br />
now type {{ic|find /home/vmailer}}<br />
<br />
you should see something like the following:<br />
{{bc|<br />
/home/vmailer/virtualdomain.tld/cactus@virtualdomain.tld<br />
/home/vmailer/virtualdomain.tld/cactus@virtualdomain.tld/tmp<br />
/home/vmailer/virtualdomain.tld/cactus@virtualdomain.tld/cur<br />
/home/vmailer/virtualdomain.tld/cactus@virtualdomain.tld/new<br />
/home/vmailer/virtualdomain.tld/cactus@virtualdomain.tld/new/1102974226.2704_0.bonk.testmail.org<br />
}}<br />
The key is the last entry. This is an actual email. If you see that, it is working.<br />
<br />
==Courier IMAP Installation==<br />
===Step 1: Install Courier IMAP===<br />
{{Accuracy|The courier packages are currently dropped from the offical repositories and moved to the [[AUR]]}}<br />
<pre><br />
pacman -S courier-imap<br />
</pre><br />
<br />
==Configure Courier IMAP==<br />
===Step 1: /etc/courier-imap/imapd===<br />
<pre><br />
ADDRESS=127.0.0.1<br />
</pre><br />
<br />
We set the listen address to LOCAL ONLY. No outside connections.<br />
<br />
===Step 2: /etc/authlib/authdaemonrc===<br />
Remove all the modules from the authmodulelist line except for authmysql like so:<br />
<pre><br />
authmodulelist="authmysql"<br />
</pre><br />
<br />
===Step 3: /etc/authlib/authmysqlrc===<br />
<br />
Replace the ''entire'' file with the following:<br />
<pre><br />
MYSQL_SERVER localhost<br />
MYSQL_USERNAME postfixuser<br />
MYSQL_PASSWORD secret<br />
MYSQL_SOCKET /run/mysqld/mysqld.sock<br />
MYSQL_DATABASE postfix<br />
# MYSQL_NAME_FIELD name<br />
MYSQL_USER_TABLE users<br />
MYSQL_CLEAR_PWFIELD password<br />
MYSQL_UID_FIELD '5003'<br />
##note, this is the uid that we set in /etc/postfix/main.cf<br />
MYSQL_GID_FIELD '5003'<br />
##note, this is the gid that we set in /etc/postfix/main.cf<br />
MYSQL_LOGIN_FIELD email<br />
MYSQL_HOME_FIELD "/home/vmailer"<br />
MYSQL_MAILDIR_FIELD concat(domain,'/',email,'/')<br />
MYSQL_QUOTA_FIELD quota<br />
</pre><br />
Where secret is the mysql password for the user postfixuser.<br />
If you are using encrypted passwords by using MySQL's encrypt function. Use "MYSQL_CRYPT_PWFIELD columnname" instead of "MYSQL_CLEAR_PWFIELD columnname".<br />
<br />
For an alternative directory structure, you could also use this setting for MAILDIR_FIELD:<br />
<pre><br />
MYSQL_MAILDIR_FIELD CONCAT(SUBSTRING_INDEX(email,'@',-1),'/',SUBSTRING_INDEX(email,'@',1),'/')<br />
</pre><br />
In this case, ''courier'' will use a directory like ''/home/vmail/exampledomain.com/exampleuser''.<br />
<br />
===Step 4: Autorun imapd on system start===<br />
If you already using [[systemd]], just run this command:<br />
{{bc|# systemctl enable authdaemond.service courier-imapd.service}}<br />
If authdaemond fails to start, make sure the folder ''/run/authdaemon'' exists.<br />
<br />
===Step 5: Fam and rpcbind===<br />
{{Accuracy|FAM should not be required anymore.|section=FAM is obsolete}}<br />
Courier-imap for arch comes compiled with FAM. This means portmap is also required. What used to be portmap is nowadays called rpcbind.<br />
If rpcbind is not already installed:<br />
<pre><br />
pacman -S rpcbind<br />
</pre><br />
<br />
Now edit /etc/fam/fam.conf<br />
<pre><br />
local_only = true<br />
idle_timeout = 0<br />
</pre><br />
Make sure the two above values are set. Then start and enable the daemon.<br />
<br />
{{bc|# systemctl enable rpcbind<br />
# systemctl start rpcbind}}<br />
<br />
===Step 6: Start courier imap===<br />
Run following command to start the ''imapd'' daemon:<br />
{{bc|# systemctl start courier-imapd}}<br />
check /var/log/mail.log or journalctl for any errors.<br />
<br />
===Step 7: Test courier..===<br />
Lets see if courier is working:<br />
<pre><br />
telnet localhost imap<br />
Trying 127.0.0.1...<br />
Connected to localhost.localdomain.<br />
Escape character is '^]'.<br />
* OK [[CAPABILITY IMAP4rev1 ... ]] Courier-IMAP ready.<br />
<br />
A LOGIN "cactus@virtualdomain.tld" "password"<br />
A OK LOGIN Ok.<br />
<br />
B SELECT "Inbox"<br />
* FLAGS (\Draft \Answered ... \Recent)<br />
* OK [[PERMANENTFLAGS (\Draft \Answered ... \Seen)]] Limited<br />
* 8 EXISTS<br />
* 5 RECENT<br />
* OK [[UIDVALIDITY 1026858715]] Ok<br />
B OK [[READ-WRITE]] Ok<br />
<br />
Z LOGOUT<br />
* BYE Courier-IMAP server shutting down<br />
Z OK LOGOUT completed<br />
Connection closed by foreign host.<br />
</pre><br />
<br />
==Squirrelmail Installation==<br />
===Step 1: Install Squirrelmail===<br />
{{Accuracy|The squirrelmail package is currently dropped from the offical repositories and moved to the [[AUR]]}}<br />
[[pacman|Install]] the {{Pkg|squirrelmail}} package which is found in the [[Official Repositories|official repositories]].<br />
<br />
==Configure Squirrelmail==<br />
===Step 1: Create secure http site (https)===<br />
We are going to create a secure http site. This is so that people can login with plain text passwords, and not have to worry about the passwords getting sniffed (or worry less).<br />
<br />
====Step 1.1: Edit /etc/httpd/conf/extra/httpd-ssl.conf====<br />
Add appropriate information. Here is an example section:<br />
<pre><br />
<VirtualHost _default_:443><br />
# General setup for the virtual host<br />
DocumentRoot "/home/httpd/site.virtual/virtualdomain.tld/html"<br />
ServerName virtualdomain.tld:443<br />
ServerAdmin noemailonthisbox@localhost<br />
<Directory "/home/httpd/site.virtual/virtualdomain.tld/html"><br />
Options -Indexes +FollowSymLinks<br />
AllowOverride Options Indexes AuthConfig<br />
Order allow,deny<br />
Allow from all<br />
</Directory><br />
</pre><br />
<br />
====Step 1.15 Include httpd-ssl.conf in httpd.conf====<br />
Simply uncomment this line in your httpd.conf:<br />
<pre><br />
#Include conf/extra/httpd-ssl.conf<br />
</pre><br />
<br />
====Step 1.2: Create the directory structure====<br />
Now, create the directory you specified in the ssl.conf file.<br />
<pre><br />
mkdir -p /home/httpd/site.virtual/virtualdomain.tld/html<br />
</pre><br />
<br />
====Step 1.3: Generate a certificate====<br />
Follow the instructions here: [[LAMP#SSL]]<br />
<br />
====Step 1.4: Restart apache and test====<br />
Make sure that https is now working, and that you can get to the secure site.<br />
<br />
===Step 2: Put squirrelmail in the directory you created===<br />
Either extract squirrelmail, or move it from where the arch package puts it, into the directory you created for the secure http site.<br />
<br />
===Step 3: Run squirrelmail config utility===<br />
cd 'squirrelmaildir'/config<br />
<pre><br />
perl conf.pl<br />
</pre><br />
<br />
Make sure you select 'D', then type in courier and hit enter. Make sure your other options are correct as well.<br />
Note: If you use php with safe mode on, make sure that the data dir is owned by the same owner as all the files in the squirrelmail directory. With safe mode off, simply follow the squirrelmail setup directions.<br />
<br />
===Step 4: Test the squirrelmail setup===<br />
Point your browser to squirrelmail/src/configtest.php. Should you get an error on directory location, make sure php.ini has been set to allow access to them (open_basedir directive).<br />
<br />
===Step 5: Test squirrelmail===<br />
Log in with the test account. You will need to login with the form of: <br />
username: cactus@virtualdomain.tld <br />
password: secret<br />
<br />
Try sending email to non-existent local accounts. You should get an immediate bounce back. <br />
Try sending email to external good email accounts, as well as non-existent ones. <br />
Just general testing stuff.<br />
If everything works fine, then you can add other accounts to the mysql database, and away you go!<br />
<br />
====Troubleshooting====<br />
If you received an error similar to <br />
{{bc|1=Warning: file_exists() [function.file-exists]: open_basedir restriction in effect. File(/var/lib/squirrelmail/data) is not within the allowed path(s): \<br />
(/srv/http/:/home/:/tmp/:/usr/share/pear/) in /home/httpd/site.virtual/virtualdomain.tld/html/squirrelmail/src/configtest.php on line 303<br />
}}<br />
then edit {{ic|/etc/httpd/httpd.conf}}, and in the section {{ic|1=<Directory "/home/httpd/site.virtual/virtualdomain.tld/html">}}, add {{ic|php_admin_value open_basedir /home/httpd/site.virtual/virtualdomain.tld/html:/var/lib/squirrelmail/}}<br />
<br />
If you get an error similar to<br />
{{bc|1=Unknown user or password incorrect.}}<br />
you may have to create your user directories within vmailer like so:<br />
<pre><br />
mkdir -p /home/vmailer/mydomain.com/username<br />
mkdir /home/vmailer/mydomain.com/username/cur<br />
mkdir /home/vmailer/mydomain.com/username/new<br />
mkdir /home/vmailer/mydomain.com/username/tmp<br />
chmod -R 750 /home/vmailer<br />
chown -R vmailer.vmail /home/vmailer<br />
</pre><br />
where mydomain.com/username is the domain/username given within mysql.<br />
<br />
==See also==<br />
*[[PostFix Howto With SASL]]<br />
*[[Simple Virtual User Mail System]]<br />
*[[Courier MTA]]<br />
*[[SOHO Postfix]]<br />
<br />
==External links==<br />
*[http://linox.be/index.php/2005/07/13/44/ Out of Office] for squirrelmail<br />
*[https://help.ubuntu.com/community/Postfix Postfix Ubuntu documentation]<br />
*[http://www.gelens.org/archlinux-mailserver/ A Simple Mailserver on Arch Linux]<br />
*[http://sherlock.heroku.com/blog/2012/02/03/setting-up-postfix-to-use-gmail-as-an-smtp-relay-host-in-archlinux/ Use Gmail as an SMTP Relay]</div>Andkorehttps://wiki.archlinux.org/index.php?title=S.M.A.R.T.&diff=255459S.M.A.R.T.2013-04-28T04:13:28Z<p>Andkore: /* Test the device health */</p>
<hr />
<div>[[Category:Storage]]<br />
S.M.A.R.T. (Self-Monitoring, Analysis, and Reporting Technology) is a supplementary component build into many modern storage devices through which devices monitor, store, and analyze the health of their operation. Statistics are collected (temperature, number of reallocated sectors, seek errors...) which software can use to measure the health of a device, predict possible device failure, and provide notifications on unsafe values.<br />
<br />
== Smartmontools ==<br />
<br />
The smartmontools package contains two utility programs ({{ic|smartctl}} and {{ic|smartd}}) to analyze and monitor storage devices. Install {{Pkg|smartmontools}} from the [[Official Repositories|official repositories]].<br />
<br />
=== Detect if device has SMART support ===<br />
<br />
To check if the device has SMART capability (it may be necessary to add {{ic|-d ata}} to specify it is an ATA derived device):<br />
<br />
# smartctl -i /dev/<device><br />
<br />
(where <device> is {{ic|sda, hda,...}}). This will give general information about the device, the last two lines will show if it is supported:<br />
<br />
SMART support is: Available - device has SMART capability.<br />
SMART support is: Enabled<br />
<br />
If SMART is not enabled, it can be enabled by doing:<br />
<br />
# smartctl -s on /dev/<device><br />
<br />
=== Test the device health ===<br />
<br />
Three type of health tests that can be performed on the device (all are safe to user data):<br />
<br />
# Short (runs tests that have a high probability of detecting device problems)<br />
# Extended (or Long; a short check with complete disk surface examination)<br />
# Conveyance (identifies if damage incurred during transportation of the device)<br />
<br />
To view the device's available tests and the time it will take to perform each test do:<br />
<br />
# smartctl -c /dev/<device><br />
<br />
To run the tests do:<br />
<br />
# smartctl -t short /dev/<device><br />
# smartctl -t long /dev/<device><br />
# smartctl -t conveyance /dev/<device><br />
<br />
==== Results ====<br />
<br />
To view the test's overall health status (compiled from all tests):<br />
<br />
# smartctl -H /dev/<device><br />
<br />
To view the test's result errors:<br />
<br />
# smartctl -l selftest /dev/<device><br />
<br />
To view the test's detailed results:<br />
<br />
# smartctl -a /dev/<device><br />
<br />
If no errors are reported the device is likely healthy. If there are a few errors this may or may not indicate a problem and should be investigated further. When a device starts to fail it is recommended to backup the data and replace it.<br />
<br />
=== Monitor devices ===<br />
<br />
Devices can be monitored in the background with use of the smartmontools daemon that will check devices periodically and optionally email any potential problems. To have devices monitored on boot, enable smartd service:<br />
<br />
systemctl enable smartd.service<br />
<br />
The smart daemon can be edited for more exact configuration in {{ic|/etc/smartd.conf}} (the configuration is well commented) otherwise all tests are run on all devices. Or, each device can be specified and all tests run by doing (uuid's and device ID can be used for more exact matching):<br />
<br />
#DEVICESCAN<br />
/dev/<device> -a<br />
<br />
Other options include:<br />
<br />
* {{ic|-n standby,q}} to run diagnostics only when device is spun-up.<br />
* Details about smartd operations can be found in: {{ic|/var/log/daemon.log}}.<br />
<br />
==== Email potential problems ====<br />
<br />
To have an email sent when a failure or new error occurs, use the {{ic|-m}} option:<br />
<br />
DEVICESCAN -m address@domain.com<br />
<br />
To be able to send the email externally (i.e. not to the root mail account) a MTA (Mail Transport Agent) or a MUA (Mail User Agent) will need to be installed and configured. Common MTAs are [[msmtp|MSMTP]] and [[SSMTP]]. Common MTUs are sendmail and [[Postfix]].<br />
<br />
Once the mail agent is setup the {{ic|-M test}} option can be used to test if an email will be sent (restart the daemon immediately to discover):<br />
<br />
DEVICESCAN -m address@domain.com -M test<br />
<br />
==== Power management ====<br />
<br />
If you use a computer under control of power management, you should instruct smartd how to handle disks in low power mode. Usually, in response to SMART commands issued by smartd, the disk platters are spun up. So if this option is not used, then a disk which is in a low-power mode may be spun up and put into a higher-power mode when it is periodically polled by smartd.<br />
<br />
DEVICESCAN -n standby,15,q<br />
<br />
More info on [http://sourceforge.net/apps/trac/smartmontools/wiki/Powermode smartmontools wiki].<br />
<br />
=== GUI Applications ===<br />
<br />
* {{App|Gsmartcontrol|A GNOME frontend for the smartctl hard disk drive health inspection tool|http://gsmartcontrol.berlios.de/home/index.php/en/Home|{{Pkg|gsmartcontrol}}}}<br />
<br />
== Resources ==<br />
<br />
* [http://smartmontools.sourceforge.net/ Smartmontools Homepage]<br />
* [https://help.ubuntu.com/community/Smartmontools Smartmontools on Ubuntu Wiki]</div>Andkore