Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I want to know if it is possible to get my backup script output or any of its errors via email using google (or any other SMTP server). I don't want to install a mail server on my local machine. What script or tool should I use to provide this functionality?

share|improve this question
add comment

3 Answers

There are other options to using mutt to send emails via an external SMTP server.

Nail will do what you want and nothing more.

Both Esmtp and sSMTP replace sendmail (or Postfix or Exim or whatever) with a simple mail relay that will relay everything via an external SMTP server.

There are advantages to installing a proper MTA. Nail, Mutt and sSMTP have no concept of a queue. If the SMTP server is down, they all throw you an error message and forget all about the email you just gave them.

ESMTP does have a queue but it is not a daemon so it doesn't actively manage the queue. It will retry every mail in the queue whenever you try to send a new email. This can cause what I like to call "London Bus Syndrome": You wait all day for an email and then 10,000 come at once.

share|improve this answer
    
I'd vote for ssmtp, it's a really great app. –  Aseques Dec 14 '11 at 7:55
add comment

There are so many good tools using email that I would strongly advise you to reconsider the idea of local mail server. If security is your concern, limit the server to accept messages from localhost only.

Now, if you agree, cron will send you emails with the output of the script. If you only want to receive messages when something goes wrong, add exit codes to the script and check them in crontab: if /backup/script >/tmp/bkup.txt; then cat /tmp/bkup.txt; fi. Or, if you want to send output to some other mailbox, write ...then mail me@somewhere </tmp/bkup; fi

And even if you still don't like this idea, you can use ssmtp to send mail in a similar fashion :)

share|improve this answer
add comment
up vote 0 down vote accepted

I have found another good Tool MSMTP for my requirement sending mails using external smtp or gmail smtp. As suggested above when i configured ssmtp i getting all mails which is junked for me like cron mails & mails generated by munin-cron & other applications.

Configuration Steps MSMTP MSMTP can read every parameter it needed from the command line.

touch ~/.msmtprc
chmod 0600 ~/.msmtprc

vim ~/.msmtprc 
# Use an external SMTP server with insecure authentication.
# (manually choose an insecure authentication method.)
# Note that the password contains blanks.

defaults

######################################################################
# A sample configuration using Gmail
######################################################################

# account name is "gmail".
# You can select this account by using "-a gmail" in your command line.
account gmail
host smtp.gmail.com
tls on
tls_certcheck off
port 587
auth login
from somebody@gmail.com
user somebody
password somesecret

######################################################################
# A sample configuration using other normal ESMTP account
######################################################################

# account name is "someplace".
# You can select this account by using "-a someplace" in your command line.
account someplace
host smtp.someplace.com
from someone@someplace.com
auth login
user someone
password somesecret

# If you don't use any "-a" parameter in your command line,
# the default account "someplace" will be used.
account default: someplace


Test
cat <<EOF | msmtp -a gmail someone@gmail.com
Subject: test

This is a test!
EOF
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.