# [SOLVED] Help sending emails through the command line

## Despot Despondency

Hey, I'm trying to work out how to email myself through the shell and I need some help. At the moment I'm trying, for example, 

```

emerge --search mailx | mail myemail@googlemail.com 

```

where I get the error

```

send-mail: Cannot open mail:25

Can't send mail: sendmail process failed with error code 1

```

I've read that I need to set the mailhub option in the /etc/ssmtp/ssmtp.conf file, but I don't know how to set it. At the moment it is just set as 'mailhub=mail'. 

Thanks for any help.Last edited by Despot Despondency on Tue Apr 07, 2009 7:35 pm; edited 1 time in total

----------

## mikegpitt

I use mutt -s on my server to send out daily status emails:

```
mutt -s "email subject line" user@email.com < /tmp/myemailtext
```

I use ssmtp as the mailserver, which it also looks like you plan to do.  The mailhub line is your remote mail server.  For instance this is my setup, which sends email though GMail:

```
mailhub=smtp.gmail.com:587

UseSTARTTLS=YES

AuthUser=senderemail@email.com

AuthPass=mypassword

FromLineOverride=YES
```

----------

## Despot Despondency

Hey, thanks for your reply. 

I've just got a stand alone computer and I want to be able to email myself various reports that are going to run on my computer automatically, like AIDE, for example.

Do I need to set up ssmtp as the mailserver to do that? 

A couple of questions about your settings. Are they all in /etc/ssmtp/ssmtp.conf?

```

mailhub=smtp.gmail.com:587 

```

587 is the port number you use for your mailserver right? How do I find out which ports are suitable for me?

```

AuthUser=senderemail@email.com

AuthPass=mypassword 

```

Is AuthUser meant to be my e-mail address, i.e. the e-mail address that I want my reports sent to? What do I put in for AuthPass?

```

UseSTARTTLS=YES 

```

what is STARTTLS? Will it be on my system by default or will I have to install something?

Sorry for all the questions, never really done this before. Is there a howto on this sort of stuff?

----------

## mikegpitt

Yes, all those lines are from by /etc/ssmtp/ssmtp.conf.  Google uses port 587 for their smtp server, but typically smtp is ran on port 25.  I believe Google uses the alternative port because they run SSL over smtp.  Authuser is the email address that is sending the email and Authpass is the login password.  The UseSTARTTLS is a variable that is needed for a Gmail setup (since it uses TLS).

In my setup ssmtp is used as a relay to the public gmail servers, which actually delivers the email.  From the ssmtp man page: 

```
It  does not attempt to provide all the functionality of sendmail: it is intended for use where other programs are the primary means of  at  last mail  delivery.
```

I never attempted, but it seems that if you want to run a full mailserver you would need a stronger smtp solution.

----------

## Despot Despondency

OK, that seems to have worked. Thanks for everything!  :Very Happy: 

----------

