How To Empty the Email Queue in Postfix
postsuper -d ALL
1 2 3 |
vim /etc/postfix/virtual /usr/sbin/postmap /etc/postfix/virtual /usr/sbin/postfix reload |
To view the Postfix deferred queue: postqueue -p To view a specific email: postcat -q {Queue ID} To delete a specific email: postsuper -d {Queue ID} Example of viewing the deferred queue and deleting a message: # postqueue -p -Queue ID- –Size– —-Arrival Time—- -Sender/Recipient——- E15B9FC221 11627 Sun Jan 6 16:47:29 MAILER-DAEMON (connect to sight.mlorol.com[46.249.46.181]: […]
NOTE: This procedure requires Postfix version 2.7 or greater! Create or edit the following three files: /etc/postfix/main.cf
1 |
sender_dependent_default_transport_maps = hash:/etc/postfix/sender_dependent_default_transport_maps |
/etc/postfix/master.cf
1 2 |
aws-email unix - n n - - pipe flags=R user=mail argv=/opt/aws/bin/ses-send-email.pl -r -k /var/spool/mail/aws-credentials -e https://email.us-east-1.amazonaws.com -f ${sender} ${recipient} |
/etc/postfix/sender_dependent_default_transport_maps yourName@gmail.com aws-email: yourName@yourDomain.com aws-email: Verify the credentials are in place and have the correct ownership and permissions:
1 2 |
chown mail:mail /var/spool/mail/aws-credentials chmod 600 /var/spool/mail/aws-credentials |
Compile the new map and reload postfix.
1 2 3 |
postmap /etc/postfix/sender_dependent_default_transport_maps postfix reload tail -f /var/log/maillog |
http://www.postfix.org/postconf.5.html#sender_dependent_default_transport_maps http://docs.amazonwebservices.com/ses/latest/DeveloperGuide/index.html?IntegratingWithServer.Postfix.html http://www.kutukupret.com/2010/01/02/postfix-bind-sender-domain-to-dedicated-outgoing-ip-address/
YMMV…
1 2 3 4 5 6 |
# postconf -d | grep ^mail_version # yum install db4-devel openssl-devel cyrus-sasl cyrus-sasl-devel pcre pcre-devel openldap openldap-devel # cd # wget http://postfix.energybeam.com/source/official/postfix-2.8.4.tar.gz # tar xvzf postfix-2.8.4.tar.gz # cd postfix-2.8.4 |
For 32-bit (i386 or i686)
1 |
# make makefiles CCARGS='-fPIC -DUSE_TLS -DUSE_SSL -DUSE_SASL_AUTH -DUSE_CYRUS_SASL -DPREFIX=\"/usr\" -DHAS_LDAP -DLDAP_DEPRECATED=1 -DHAS_PCRE -I/usr/include/openssl -I/usr/include/sasl -I/usr/include' AUXLIBS='-L/usr/lib -L/usr/lib/openssl -lssl -lcrypto -L/usr/lib/sasl2 -lsasl2 -lpcre -lz -lm -lldap -llber -Wl,-rpath,/usr/lib/openssl -pie -Wl,-z,relro' OPT='-O' DEBUG='-g' |
For 64-bit (x86_64)
1 |
# make makefiles CCARGS='-fPIC -DUSE_TLS -DUSE_SSL -DUSE_SASL_AUTH -DUSE_CYRUS_SASL -DPREFIX=\"/usr\" -DHAS_LDAP -DLDAP_DEPRECATED=1 -DHAS_PCRE -I/usr/include/openssl -I/usr/include/sasl -I/usr/include' AUXLIBS='-L/usr/lib64 -L/usr/lib64/openssl -lssl -lcrypto -L/usr/lib64/sasl2 -lsasl2 -lpcre -lz -lm -lldap -llber -Wl,-rpath,/usr/lib64/openssl -pie -Wl,-z,relro' OPT='-O' DEBUG='-g' |
For all..
1 2 3 4 |
# make # make upgrade # service postfix restart # postconf -d | grep ^mail_version |
Note: the following files or directories still exist but are no longer part of Postfix and can be deleted:
1 2 3 4 |
rm /etc/postfix/postfix-files rm /etc/postfix/postfix-script rm /etc/postfix/post-install rm /usr/share/doc/postfix-2.3.3/README_FILES/QMQP_README |
Resources Original post by Steve Jenkins: http://stevejenkins.com/blog/2011/01/building-postfix-2-8-on-rhel5-centos-5-from-source/ http://www.postfix.org/INSTALL.html
By default, the Postfix SMTP server accepts any sender address. You block email addresses using the sender_access file:
1 2 3 4 5 6 7 8 9 10 11 12 |
# cd /etc/postfix # vi sender_access baduser@baddomain.com REJECT # postmap hash:sender_access # vi recipient_access baduser@baddomain.com REJECT # postmap hash:recipient_access # vi main.cf smtpd_sender_restrictions = check_sender_access hash:/etc/postfix/sender_access smtpd_recipient_restrictions = check_recipient_access hash:/etc/postfix/recipient_access (make sure these are the FIRST entry on the lines) # /etc/init.d/postfix restart |
Edit the aliases configuation file: # vim /etc/aliases Regenerate your aliases database file: # newaliases Reload postfix: # postfix reload
Below info copied from http://yocum.org/faqs/postfix-tls-sasl.html Verify that the correct libraries have been linked in: # ldd /usr/libexec/postfix/smtpd You should see the following: smtpd: libsasl2.so.2 => /usr/local/lib/libsasl2.so.2 (0x28096000) libssl.so.3 => /usr/local/lib/libssl.so.3 (0x280aa000) libcrypto.so.3 => /usr/local/lib/libcrypto.so.3 (0x280db000) If you see libsasl2, libssl, and libcrypto, congratulations — the server is ready to support SASL and TLS. Generate an […]
Below info copied from http://www.postfix.org/SASL_README.html#server_sasl_enable Make sure saslauthd is running first. Edit /etc/postfix/main.cf: smtpd_sasl_type = cyrus smtpd_sasl_auth_enable = yes broken_sasl_auth_clients = yes smtpd_sasl_security_options = noanonymous smtpd_sasl_authenticated_header = yes smtpd_recipient_restrictions = permit_sasl_authenticated {other options that were already there} # postfix reload To test (you supply the items in bold): % telnet server.example.com 25 … 220 server.example.com […]
Edit /etc/postfix/access and add entries like: baduser@baddomain.com 550 No such user here Then run the following command: postmap /etc/postfix/access Edit /etc/postfix/main.cf: smtpd_recipient_restrictions = check_recipient_access hash:/etc/postfix/access, {any other options already there…} Then run the following command: postfix reload