Ubuntu – How to setup sendmail, postfix, or dovecot so that perl can send emails

emailperlserver

Direct Question: I want to enable Perl to send emails. What package(s) should I install to setup a simplistic email server: no need for incoming, only outgoing. I can forward through gmail's SMTP if that's best?

Background: I am programmer with a nightly build script written in Perl. I would like to email myself the results of my nightly builds (especially if there's an error).

I've read about the perl package Mail::Sendmail briefly, but if something else is more appropriate, please tell me!!

I tried the simple aptget install sendmail, but that doesn't seem to work. I get the following errors:

Server said: 421 4.3.0 collect: Cannot write ./dfp1PFXl7W020719 (bfcommit, uid=0, gid=120): No such file or directory
message transmission error (421 4.3.0 collect: Cannot write ./dfp1PFXl7W020719 (bfcommit, uid=0, gid=120): No such file or directory
)
Server said: 421 4.3.0 collect: Cannot write ./dfp1PFXl7W020719 (bfcommit, uid=0, gid=120): No such file or directory

I've googled this problem a bit and tried a few things — adding my username to /etc/mail/trusted-users and such, but to no avail.

In other words, I would be most grateful if you could provide simple instructions for setting up an outgoing mail server. I really don't understand the specifics, but as I understand, I need to forward the mail through an existing SMTP server — so I can use my gmail account if need be (that's where I want to send the logs anyway). Any suggestions would be most greatly appreciated.

Best Answer

All of them are too much tool for the job. ssmtp does this - but only this.

sudo apt-get install ssmtp

(This will remove postfix or sendmail if installed.)

sudoedit /etc/ssmtp/ssmtp.conf

And the contents of that file:

Root=your_email@gmail.com
Mailhub=smtp.gmail.com:465
RewriteDomain=gmail.com
AuthUser=your_gmail_username # (before the @gmail.com part)
AuthPass=your_gmail_password
FromLineOverride=Yes
UseTLS=Yes