Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
ssmtp email from a script problems [SOLVED]
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Networking & Security
View previous topic :: View next topic  
Author Message
dakster
Apprentice
Apprentice


Joined: 26 Jul 2004
Posts: 178
Location: New England

PostPosted: Sun Jan 14, 2007 6:16 pm    Post subject: ssmtp email from a script problems [SOLVED] Reply with quote

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
Back to top
View user's profile Send private message
ecosta
Guru
Guru


Joined: 09 May 2003
Posts: 477
Location: Brussels,BE

PostPosted: Sun Jan 14, 2007 6:49 pm    Post subject: Reply with quote

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

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
_________________
Linux user #201331
A8N-SLI Delux / AMD64 X2 3800+ / 1024 MB RAM / 5 x 250 GB SATA RAID 1/5 / ATI Radeon X700 256MB.
Back to top
View user's profile Send private message
dakster
Apprentice
Apprentice


Joined: 26 Jul 2004
Posts: 178
Location: New England

PostPosted: Sun Jan 14, 2007 9:14 pm    Post subject: Reply with quote

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?
Back to top
View user's profile Send private message
ecosta
Guru
Guru


Joined: 09 May 2003
Posts: 477
Location: Brussels,BE

PostPosted: Wed Jan 17, 2007 8:16 am    Post subject: Reply with quote

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:
Code:

# 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>
host <mailserverip>
from <user@domain.com>



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

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

Hope this helps,
-Ed
_________________
Linux user #201331
A8N-SLI Delux / AMD64 X2 3800+ / 1024 MB RAM / 5 x 250 GB SATA RAID 1/5 / ATI Radeon X700 256MB.
Back to top
View user's profile Send private message
ecosta
Guru
Guru


Joined: 09 May 2003
Posts: 477
Location: Brussels,BE

PostPosted: Wed Jan 17, 2007 8:33 am    Post subject: Reply with quote

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

~/.msmtprc
Code:

# 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
Code:

# 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
Code:

-----BEGIN CERTIFICATE-----
M11DmTCCAwKgAwIBAgIJAKauzKQtCzZfMA0GCSqGSIb3DvEBBQUAMIGQMQsWCQYD
...
lD7gsCT/OOOX7veBMy==
-----END CERTIFICATE-----

_________________
Linux user #201331
A8N-SLI Delux / AMD64 X2 3800+ / 1024 MB RAM / 5 x 250 GB SATA RAID 1/5 / ATI Radeon X700 256MB.
Back to top
View user's profile Send private message
thuk
n00b
n00b


Joined: 26 Oct 2005
Posts: 31
Location: Canberra, Australia

PostPosted: Wed Jan 17, 2007 10:56 am    Post subject: Reply with quote

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:

Code:
useSTARTTLS=YES
AuthUser=mailuser
AuthPass=mailpass


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

Hope this helps!

thuk
Back to top
View user's profile Send private message
dakster
Apprentice
Apprentice


Joined: 26 Jul 2004
Posts: 178
Location: New England

PostPosted: Wed Jan 17, 2007 1:23 pm    Post subject: Reply with quote

Thanks for the tips, I'll give 'em a try tonight when I get home.
Back to top
View user's profile Send private message
dakster
Apprentice
Apprentice


Joined: 26 Jul 2004
Posts: 178
Location: New England

PostPosted: Fri Jan 19, 2007 12:45 am    Post subject: Reply with quote

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....
Back to top
View user's profile Send private message
thuk
n00b
n00b


Joined: 26 Oct 2005
Posts: 31
Location: Canberra, Australia

PostPosted: Fri Jan 19, 2007 11:45 am    Post subject: Reply with quote

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:

Code:

root=postmaster
mailhub=smtp.gmail.com:587
UseSTARTTLS=YES
AuthUser=(my account name)
AuthPass=(my password)
FromLineOverride=YES


Cheers,

thuk
Back to top
View user's profile Send private message
oxffffff
n00b
n00b


Joined: 07 Nov 2005
Posts: 29

PostPosted: Fri Jan 19, 2007 12:46 pm    Post subject: Reply with quote

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.
Back to top
View user's profile Send private message
dakster
Apprentice
Apprentice


Joined: 26 Jul 2004
Posts: 178
Location: New England

PostPosted: Fri Jan 19, 2007 3:06 pm    Post subject: Reply with quote

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!
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Networking & Security All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum