# ssmtp email from a script problems [SOLVED]

## dakster

I have a Linksys slug (arm based) running gentoo, and I'm trying to set up sending emails from scripts for this little embedded computer. I've set up a gmail account for this computer and emerged ssmtp successfully. My ssmtp.conf file consists of:

root=postmaster

mailhub=smtp.gmail.com:465

UseTLS=YES

And the command I'm using is:

(echo "Subject: foo sub"; echo; cat testEmail) | ssmtp -au "USERNAME" -ap "PASSWORD" "myemail@gmail.com"

This command proceeds to hang indefinitely. The error I'm getting in my /var/log/messages is:

Jan 14 12:51:15 bubo sSMTP[6906]: Unable to set UseTLS="YES"

This pops up immediately in the log when I execute the command. Any tips? I don't know anything about mail systems to be honest, I'm sure it's something simple, but googling hasn't turned up anything....Last edited by dakster on Fri Jan 19, 2007 3:06 pm; edited 1 time in total

----------

## ecosta

I've had a few probs with ssmtp so I changed to msmtp and now I am happy  :Smile: 

This is what I have incase you dicide to give it a go

~/.msmtprc

   account <accountname>

   host <mailserverip>

   from <user@domain.com>

In .muttrc I just set the following

   set sendmail="/usr/bin/msmtp -a <accountname>"

Then just email and forget about it...

   $ mutt -s "TEST" john@doe.com

Hope this helps

 -Ed

----------

## dakster

Hmm, that mutt command seems to be an interactive command, which won't work for scripting. I'm trying now to just use msmtp, but so far it's just sitting there. Anyone know the syntax for a command line email using msmtp?

----------

## ecosta

Sorry for late reply,

You can use it in a script, I do it all the time.  This is what I have on my boxes:

```

# ls -ld `which sendmail`

lrwxrwxrwx 1 root root 14 2007-01-06 12:10 /usr/sbin/sendmail -> /usr/bin/msmtp

```

The fact that sendmail is a link to msmtp should fix any probs you may have.

and for msmtp, I use what I gave you before.

 *Quote:*   

> 
> 
> ~/.msmtprc
> 
> account <accountname>
> ...

 

I personaly use nail to send my mail and it works fine in scripts, but mailx, mutt, ... will also work fine.

```

nail -s "TEST" jdoe@example.com < /dev/null

```

Hope this helps,

 -Ed

----------

## ecosta

Just realised you where using TLS... this is what I did to get TLS working

~/.msmtprc

```

# Set default values for all following accounts.

defaults

tls on

tls_trust_file ~/.msmtp/certificate

logfile ~/.msmtp/msmtp.log

# foobar

account foobar

host mail.domain.com

from jdoe@gmail.com

auth on

user jdoe@gmail.com

password <mypassword>

# Set a default account

account default : foobar

```

This is a list of files and permissions

```

# ls -lR .msmtp*

-r-------- 1 root root  361 2006-11-14 14:13 .msmtprc

.msmtp:

total 92

-r-------- 1 root root  1310 2006-11-14 13:48 certificate

-r-------- 1 root root 85403 2007-01-17 09:31 msmtp.log

```

cat certificate

```

-----BEGIN CERTIFICATE-----

M11DmTCCAwKgAwIBAgIJAKauzKQtCzZfMA0GCSqGSIb3DvEBBQUAMIGQMQsWCQYD

...

lD7gsCT/OOOX7veBMy==

-----END CERTIFICATE-----

```

----------

## thuk

Hi There,

I'm using ssmtp with secure authentication as I think you want to.  You might try adding a few extra lines to your ssmtp.conf:

```
useSTARTTLS=YES

AuthUser=mailuser

AuthPass=mailpass
```

(change the user/pass to your gmail user/pass)

Hope this helps!

thuk

----------

## dakster

Thanks for the tips, I'll give 'em a try tonight when I get home.

----------

## dakster

Hmm, I tried the ssmtp route, my config file (/etc/ssmtp/ssmtp.conf) is now:

root=postmaster

mailhub=smtp.gmail.com:465

UseTLS=YES

UseSTARTTLS=YES

AuthUser=(my account name)

AuthPass=(my password)

and I'm getting these errors in my logs:

Jan 18 19:49:45 bubo sSMTP[10529]: Unable to set UseTLS="YES"

Jan 18 19:49:45 bubo sSMTP[10529]: Unable to set UseSTARTTLS="YES"

I added a use flag "tls" and recompiled, nothing. Any ideas on this ssmtp before I switch over to msmtp? ssmtp seems simpler to me, I was hoping to get it working....

----------

## thuk

Check some of the other posts on the forum.  Some ones to start with:

TIP: gmail and ssmtp

HOWTO ssmtp

I don't actually use ssmtp with gmail, but I would have assumed gmail would be similar to any other secure ssmtp host.  From first glance try:

```

root=postmaster

mailhub=smtp.gmail.com:587

UseSTARTTLS=YES

AuthUser=(my account name)

AuthPass=(my password)

FromLineOverride=YES

```

Cheers,

thuk

----------

## oxffffff

Did you compile ssmtp with the ssl USE flag turned on?

It will pull in openssl, but I think this is needed if you want to use TLS.

PS: as "emerge -pv ssmtp" will show you, there is no "tls" USE flag.

PPS: assuming you are using uclibc on the slug and not glibc, you will be hit by bug #145456. See there for a patch that still awaits being applied.

----------

## dakster

Finally got it working by doing what oxffffff said, and the added bits from this page:

http://www.destr0yr.com/article.php/Gmail_and_sSMTP

Works great now, thanks for the help!

----------

