Postfix: Difference between revisions
Adds DO hack |
m Text replacement - "<(\/?)source" to "<$1syntaxhighlight" |
||
| (6 intermediate revisions by one other user not shown) | |||
| Line 1: | Line 1: | ||
[[File:Internet-mail.svg|right|thumb|300px|link=http://www.postfix.org|visit www.postfix.org]] | |||
Notes on using Postfix <ref>loosely following the info at http://braiden.org/?p=15</ref>. Quick and dirty procedure for setting up Postfix on a new machine that needs email. | Notes on using Postfix <ref>loosely following the info at http://braiden.org/?p=15</ref>. Quick and dirty procedure for setting up Postfix on a new machine that needs email. | ||
| Line 5: | Line 7: | ||
Add '''[[Postfix]]''' Mail Transfer Agent as satellite smarthosting through Google, install mail utilities, setup an alias for root's mail and test it all | Add '''[[Postfix]]''' Mail Transfer Agent as satellite smarthosting through Google, install mail utilities, setup an alias for root's mail and test it all | ||
<ol> | <ol> | ||
<li>< | <li><syntaxhighlight lang="bash"> sudo su - </syntaxhighlight> | ||
<li>< | <li><syntaxhighlight lang="bash"> apt-get install postfix </syntaxhighlight> | ||
<li>< | <li><syntaxhighlight lang="bash"> apt-get install bsd-mailx | ||
# or | |||
apt-get install mailutils | |||
</syntaxhighlight> | |||
<li><pre>cat <<HERE | sudo tee /etc/postfix/main.cf > /dev/null | <li><pre>cat <<HERE | sudo tee /etc/postfix/main.cf > /dev/null | ||
# work-around for Digital Ocean's blocking of IPv6 for email | # work-around for Digital Ocean's blocking of IPv6 for email | ||
smtp_bind_address = 0.0.0.0 | smtp_bind_address = 0.0.0.0 | ||
# or set inet_protocols = ipv4 | |||
# satellite configuration | # satellite configuration | ||
smtp_use_tls = yes | smtp_use_tls = yes | ||
| Line 17: | Line 23: | ||
smtp_sasl_security_options = noanonymous | smtp_sasl_security_options = noanonymous | ||
smtp_sasl_tls_security_options = noanonymous | smtp_sasl_tls_security_options = noanonymous | ||
# list of CAs to trust when verifying server certificate | |||
smtp_tls_CAfile = /etc/ssl/certs/ca-certificates.crt | |||
HERE | HERE | ||
</pre> | </pre> | ||
<li>< | <li><syntaxhighlight lang="bash"> echo "smtp.gmail.com me@example.com:PASSWORD" > /etc/postfix/sasl_passwd </syntaxhighlight> | ||
<li>< | <li><syntaxhighlight lang="bash"> postmap /etc/postfix/sasl_passwd </syntaxhighlight> | ||
<li>< | <li><syntaxhighlight lang="bash"> chmod 640 /etc/postfix/sasl_passwd* </syntaxhighlight> | ||
<li>< | <li><syntaxhighlight lang="bash"> chown postfix:postfix /etc/postfix/sasl_passwd* </syntaxhighlight> | ||
<li>< | <li><syntaxhighlight lang="bash"> /etc/init.d/postfix restart </syntaxhighlight> | ||
<li>< | <li><syntaxhighlight lang="bash"> echo "root: me@example.com" >> /etc/aliases && newaliases </syntaxhighlight> | ||
<li>< | <li><syntaxhighlight lang="bash"> echo test |mail -s "test mail sent to external" greg.rundlett@gmail.com </syntaxhighlight> | ||
<li>< | <li><syntaxhighlight lang="bash"> echo test |mail -s "test mail sent to root" root </syntaxhighlight> | ||
</ol> | </ol> | ||
== Security == | |||
https://drownattack.com/postfix.html illustrates how to secure your Postfix installation against weak encryption. | |||
== Version == | |||
Run <code>postconf -d | grep mail_version</code> to find out your Postfix version. | |||
== Log == | |||
All mail activity goes to the mail log, and you can see what's going on there: | |||
<syntaxhighlight lang="bash"> | |||
sudo tail -100 /var/log/mail.log | |||
</syntaxhighlight> | |||
== Delete Mail == | |||
Postfix stores mails in a queue before sending it. Sometimes you wish to remove the mails from the queue but wonder how. Postfix offers the <code>postsuper</code> command which can be used to delete unsent mails from the queue. Before removing the mail from the queue it is good idea to list all mails in the queue. By issuing the command: | |||
<syntaxhighlight lang="bash"> | |||
mailq | |||
</syntaxhighlight> | |||
you will list all of the mails which are queued or simply timed out for some reason. | |||
If you want to remove a mail from the "mailq" type: | |||
<syntaxhighlight lang="bash"> | |||
postsuper -d mailID | |||
</syntaxhighlight> | |||
where mailID is the ID of the message in the mail queue. | |||
Issuing the command: | |||
<syntaxhighlight lang="bash"> | |||
postsuper -d ALL | |||
</syntaxhighlight> | |||
will delete all queued messages from the mailq. | |||
{{References}} | {{References}} | ||
[[Category:Email]] | [[Category:Email]] | ||
[[Category:Security]] | |||