I am running an Ubuntu 14.04 (Linux) server. I have installed and configured Postfix and OpenDKIM very nicely on the server; I can send emails to myself with commands such as
echo hi | sendmail root, and postfix/opendkim will add headers such as
DKIM-Signature, forward the email to my personal email address, and everything works great.
Now I would like to create an application that runs in a Docker container and can send emails with the same ease. In particular, I don't want to worry about adding headers like
Message-Id, and I don't want to do very much configuration or software installation inside the container itself.
What is the best way to do this?
Is there any way to let the container run the
sendmail exectuable on the host?
I tried making a connection to Postfix from a container using the SMTP protocol on port 25, but Postfix seems to treat messages received in that way differently; I think it didn't add any headers so the message got outright rejected as spam by gmail (it wasn't even good enough to be placed into my Spam folder).
Here the maillog content
Sep 28 23:35:52 dantooine postfix/smtpd: connect from unknown[172.17.0.95] Sep 28 23:35:52 dantooine postfix/smtpd: DD457889B: client=unknown[172.17.0.95] Sep 28 23:35:52 dantooine postfix/cleanup: DD457889B: message-id=<> Sep 28 23:35:52 dantooine spamd: spamd: connection from localhost [::1]:59471 to port 783, fd 6 Sep 28 23:35:52 dantooine spamd: spamd: handle_user (getpwnam) unable to find user: 'someone' Sep 28 23:35:52 dantooine spamd: spamd: still running as root: user not specified with -u, not found, or set to root, falling back to nobody Sep 28 23:35:52 dantooine spamd: spamd: processing message (unknown) for someone:65534 Sep 28 23:35:52 dantooine spamd: spamd: clean message (2.5/5.0) for someone:65534 in 0.0 seconds, 331 bytes. Sep 28 23:35:52 dantooine spamd: spamd: result: . 2 - MISSING_DATE,MISSING_FROM,MISSING_MID,UNPARSEABLE_RELAY scantime=0.0,size=331,user=someone,uid=65534,required_score=5.0,rhost=localhost,raddr=::1,rport=59471,mid=(unknown),autolearn=no autolearn_force=no Sep 28 23:35:52 dantooine opendkim: DD457889B: can't determine message sender; accepting Sep 28 23:35:53 dantooine postfix/qmgr: DD457889B: from=<email@example.com>, size=275, nrcpt=1 (queue active) Sep 28 23:35:53 dantooine postfix/smtpd: disconnect from unknown[172.17.0.95] Sep 28 23:35:53 dantooine postfix/smtp: DD457889B: to=<firstname.lastname@example.org>, relay=gmail-smtp-in.l.google.com[2607:f8b0:4003:c05::1b]:25, delay=0.25, delays=0.12/0.01/0.03/0.09, dsn=5.7.1, status=bounced (host gmail-smtp-in.l.google.com[2607:f8b0:4003:c05::1b] said: 550-5.7.1 [fd17:8b70:893a:44bf:fe73:6c21] Our system has detected that 550-5.7.1 this message is likely unsolicited mail. To reduce the amount of spam 550-5.7.1 sent to Gmail, this message has been blocked. Please visit 550-5.7.1 http://support.google.com/mail/bin/answer.py?hl=en&answer=188131 for 550 5.7.1 more information. su20si7357528oeb.94 - gsmtp (in reply to end of DATA command)) Sep 28 23:35:53 dantooine postfix/cleanup: 254E688A0: message-id=<20140928233553.254E688A0@myserver.example.com> Sep 28 23:35:53 dantooine postfix/bounce: DD457889B: sender non-delivery notification: 254E688A0 Sep 28 23:35:53 dantooine postfix/qmgr: 254E688A0: from=<>, size=3374, nrcpt=1 (queue active) Sep 28 23:35:53 dantooine postfix/qmgr: DD457889B: removed Sep 28 23:35:53 dantooine postfix/virtual: 254E688A0: to=<email@example.com>, relay=virtual, delay=0.01, delays=0/0/0/0, dsn=2.0.0, status=sent (delivered to maildir) Sep 28 23:35:53 dantooine postfix/qmgr: 254E688A0: removed