# How to get simple mail command working

## djcronos

Hello,

I want my Gentoo box to be able to send out simple e-mails to my gmail account.  Basically, I'm doing some mysqldumps and want to email my gmail account when they are finished.

I've tried emerging Postfix, qmail, sendmail, netqmail, and I know i'm overlooking something.  I've tried to follow the tutorial at http://gentoo-wiki.com/HOWTO_Email_System_for_the_Home_Network#Sending but it's a little too much for what i'm looking for.

How can I set up basic e-mailing for what I need it for?  Thanks in advance.

----------

## Nil_Spaar

You only need ssmtp for this.

In /etc/ssmtp/ssmtp.conf you have to set where to send mail e.g. "mailhub=smtp.gmail.com".

Then you should be able to send mail with 

```
ssmtp -auUsername -apPassword "you@gmail.com" < mailfile
```

This requires "mailfile" to already be a valid mail. To create it on the fly you might use something like 

```
(echo "Subject: foo sub"; echo; cat $mailtext) | ssmtp ...
```

You also might have to add a From: line but from what I remember GMail sets it automatically if it's missing.

----------

## nixnut

Moved from Installing Gentoo to Networking & Security.

Not about getting gentoo installed, so moved here.

----------

## Bojan

You could also do it with mailx. It couldn't be easier.

```
echo "I finished my work" | mailx -s "A message from shell script" me@gmail.com
```

----------

## albright

maybe this page

http://www.methods.co.nz/python/

might help

----------

## djcronos

Hi all,

Thanks for all the replies, but I think something is up.  First, I tried ssmtp and edited the /etc/ssmtp/ssmtp.conf file to use gmail.  Since I know that the smtp.gmail.com uses port 587 to send mail, I changed the mailhub line to look like:

```

mailhub=smtp.gmail.com:587

```

No luck, I get the following:

```

Use PrivateKey: Success

ssmtp: Cannot open smtp.gmail.com:587

```

I am also using TLS, since I know Gmail requires that as well.

Anyone get this ssmtp to work with Gmail?

Thanks.

----------

## Bojan

You don't need TLS to send mail TO somewhere from your MTA ...

----------

## djcronos

Okay I seemed to have been able to get it working, somewhat.  I can now connect to the gmail server, but for some reason I don't think it's sending anything.  I've tried sending a few emails to different email addresses, even my own gmail address, and none go through.

Where can I check to see if they went through?

Here's my ssmtp.conf:

```

root=******@gmail.com

mailhub=smtp.gmail.com:587

rewriteDomain=

hostname=*****@gmail.com

UseSTARTTLS=YES

AuthUser=*****

AuthPass=*****

FromLineOverride=YES

```

I don't get a fail or anything - it appears as if the mail was sent (well, from the CLI perspective).

Any ideas?

----------

## Bojan

After I've done some googling I've seen that relaying mail through smtp.gmail.com is possible. But I still suggest you that you relay mail through your ISP's smtp server. I think this would be a lot easier.

----------

