@da1 - Thanks, I reinstalled ssmtp with logging and turned on debugging - but can't get it to send.
I think the problem is that postfix on the mailserver is configured to use SSL key/cert.
If I lazily test this by copying the key/cert from postifix's smtpd.pem to one I've made in the webserver,
/var/log/maillog shows ssmtp starting to authenticate but fails.
I've set up a private SSL cert to access squirrelmail on the webserver by creating a CA etc on it.
My guess is I would have to remake the key/cert for postfix the same way to generate a key for the webserver.
Then I'd update ssmtp.conf in the webserver to authenticate with postfix in the mailserver?
If you or anyone has experience with this, please confirm, as I'd like to complete my learning about this as I may have need for ssmtp authenticated forwarding/relaying in future.
Here's the relevant part of my
/usr/local/etc/postfix/main.cf
Code:
# SASL CONFIG
#
broken_sasl_auth_clients = yes
smtpd_sender_restrictions = permit_sasl_authenticated, permit_mynetworks
smtpd_recipient_restrictions =
permit_mynetworks,
permit_sasl_authenticated,
reject_non_fqdn_hostname,
reject_non_fqdn_sender,
reject_non_fqdn_recipient,
reject_unauth_destination,
reject_unauth_pipelining,
reject_invalid_hostname,
reject_rbl_client list.dsbl.org,
reject_rbl_client bl.spamcop.net,
reject_rbl_client sbl-xbl.spamhaus.org
check_policy_service unix:private/spf-policy
smtpd_sasl_auth_enable = yes
smtpd_sasl_authenticated_header = yes
smtpd_sasl_local_domain = $myhostname
smtpd_sasl_security_options = noanonymous
smtpd_sasl_type = dovecot
smtpd_sasl_path = private/auth
# TLS CONFIG
#
smtp_use_tls = yes
smtpd_use_tls = yes
smtp_tls_note_starttls_offer = yes
smtpd_tls_key_file = /etc/ssl/postfix/smtpd.pem
smtpd_tls_cert_file = /etc/ssl/postfix/smtpd.pem
smtpd_tls_CAfile = /etc/ssl/postfix/smtpd.pem
smtpd_tls_loglevel = 0
smtpd_tls_received_header = yes
smtpd_tls_session_cache_timeout = 3600s
tls_random_source = dev:/dev/urandom
I setup the mailserver based on this guide:
http://www.purplehat.org/?page_id=4
I think I should stick with sendmail for now, as it works without authenticating.
(I guess this is because of the
permit_mynetworks setting in
/usr/local/etc/postfix/main.cf?
Or perhaps that just restricts sasl authentication to subnet servers?)
My reasoning being that I don't want to have any copy of authentication info for the mailserver in the webserver.
I'm up for any advice in this regard, as my priorities are:
- speed of email delivery from webserver to mailserver,
- privacy of email delivery - directly from server to server - not leaving the subnet,
- security - all mail related authentication info should be on the mailserver only,
and the webserver shouldn't accept/receive any mail from anywhere - only send to the mailserver.
@usdmatt - Thanks, I followed those steps and sendmail is now configured the same. And it works.
It still takes about 20-25secs for mail to be received by the mailserver.
Here's the
/var/log/maillog
Code:
Aug 2 15:33:09 webserver sendmail[1201]: q723X907001201: from=www, size=173, class=0, nrcpts=1, msgid=<201208020333.q723X907001201@webserver.mydomain.com>, relay=www@localhost
Aug 2 15:33:10 webserver sm-mta[1202]: q723X9Mt001202: from=<www@webserver.mydomain.com>, size=424, class=0, nrcpts=1, msgid=<201208020333.q723X907001201@webserver.mydomain.com>, proto=ESMTP, daemon=IPv4, relay=localhost [127.0.0.1]
Aug 2 15:33:10 webserver sendmail[1201]: q723X907001201: to=emailaddress@mydomain.com, ctladdr=www (80/80), delay=00:00:01, xdelay=00:00:01, mailer=relay, pri=30173, relay=[127.0.0.1] [127.0.0.1], dsn=2.0.0, stat=Sent (q723X9Mt001202 Message accepted for delivery)
Aug 2 15:33:11 webserver sm-mta[1204]: STARTTLS=client, relay=mailserver.mydomain.com., version=TLSv1/SSLv3, verify=FAIL, cipher=DHE-RSA-AES256-SHA, bits=256/256
Aug 2 15:33:52 webserver sm-mta[1204]: q723X9Mt001202: to=<emailaddress@mydomain.com>, ctladdr=<www@webserver.mydomain.com> (80/80), delay=00:00:42, xdelay=00:00:42, mailer=relay, pri=30424, relay=mailserver.mydomain.com. [192.168.0.183], dsn=2.0.0, stat=Sent (Ok: queued as E452922B3F)
Is the delay because it first tries TLS authentication and then fails?
If I'm going to continue using sendmail, are there any security hazards/tips I should immediately fix like blocking particular ports?