7

I'd like to set up some sort of mail server to send emails from from my gmail account to another email. How can I do this?

jrg
  • 60,101
  • 54
  • 172
  • 246

1 Answers1

7

First, install sSMTP, since in this instance postfix is overkill. Yes, this will remove postfix. Do we care? Not really.

sudo apt-get install ssmtp
  1. Configure sSMTP by editing /etc/ssmtp/ssmtp.conf
#Config file for sSMTP sendmail
#
# The person who gets all mail for userids < 1000
# Make this empty to disable rewriting.
root=yourusername@gmail.com
#I recommend setting this 

mailhub=smtp.gmail.com:587

# Where will the mail seem to come from?
rewriteDomain=

#The full hostname
hostname=[some hostname here]
UseTLS=YES
UseSTARTTLS=YES
AuthMethod=LOGIN
AuthUser=yourusername@gmail.com
AuthPass=yourpassword

# Are users allowed to set their own From: address?
# YES - Allow the user to specify their own From: address
# NO - Use the system generated From: address
# This is optional if you're going to use revaliases - I didn't
FromLineOverride=YES

Now, we need to set permissions on /etc/ssmtp/ssmtp.conf to help (it isn't foolproof) protect your plaintext password.

sudo chown root:nagios /etc/ssmtp/ssmtp.conf
sudo chmod 640 /etc/ssmtp/ssmtp.conf

Restart nagios and you should be set.

sudo service nagios3 restart
jrg
  • 60,101
  • 54
  • 172
  • 246
  • Any chance you could add instructions for postfix also? – user66001 Aug 10 '14 at 21:46
  • @user66001: Installing and configuring postfix was neither requested nor needed by the OP. There are plenty of (great) answers for that already. – MestreLion Mar 31 '21 at 23:24
  • As of 2021, one should use `msmtp` (or similar) instead of `ssmtp`, which is now an almost abandoned project. – MestreLion Mar 31 '21 at 23:25
  • @MestreLion - The OP wasn't specific about what mail server worked for them, so no harm in asking for the same solution using a different mail server. Instead of suggesting what you take exception to on a 7 year old post(!), and eluding to other answers that I recall looking for an not finding, how about actually linking to these (great) answers you mention. P.S The OP didn't ask for a 2021 update to the solution provided, either... – user66001 Apr 02 '21 at 04:56
  • @user66001: I didn't mean to be rude or unhelpful. My point was: OP had a very specific and simple scenario, so @jrg was on the spot to say that _postfix is overkill_ for that particular case, and suggested `ssmtp`. Yes, no harm in asking for a postfix solution, but that would be completely out of the scope for his answer. Postfix is a big deal, and it deserves its own question (and a much longer answer) – MestreLion Apr 02 '21 at 08:38
  • @MestreLion - I also come off badly in textual form. OP didn't state what e-mail service he wanted to use for the solution, so saying that postfix info in an answer is out of scope is incorrect. I was curious about a postfix solution (not enough to ask my own question, nor search for others) and figured perhaps with the mention at least some examples on why it is overkill/a link to a page about setting up postfix for this operation, wouldn't hurt at least, and be helpful to illustrate the point (I have no experience setting up either) to others at best.However it appears to be a mute point now – user66001 Apr 04 '21 at 10:15