You are not logged in.

#1 2008-10-08 22:12:30

crouse
Arch Linux f@h Team Member
From: Iowa - USA
Registered: 2006-08-19
Posts: 907
Website

SSMTP with GMail

SSMTP with GMail
In arch this is very simple to setup wink
If your like me, you don't need a full blown mail server, since I use gmail (my @archlinux.us email )for most everything.  But it's nice to have a quick easy way to get automated mail off your machine and to a mail hub. Enter ssmtp wink

[crouse@VistaCrusher ~]$ pacman -Ss ssmtp
extra/ssmtp 2.62-2
    Extremely simple MTA to get mail off the system to a mailhub

Installing in arch.... piece of cake.....

[root@VistaCrusher ~]# pacman -S ssmtp
resolving dependencies...
looking for inter-conflicts...

Targets (1): ssmtp-2.62-2

Total Download Size:    0.02 MB
Total Installed Size:   0.07 MB

Proceed with installation? [Y/n] y
:: Retrieving packages from extra...
 ssmtp-2.62-2-x86_64       21.4K   63.6K/s 00:00:00 [######################] 100%
checking package integrity...
(1/1) checking for file conflicts                   [######################] 100%
(1/1) installing ssmtp                              [######################] 100%
[root@VistaCrusher ~]#

Now you have 2 files to edit.

In /etc/ssmtp/ssmtp.conf, set the following:

root=youraccount@gmail.com
mailhub=smtp.gmail.com:587
rewriteDomain=
hostname=youraccount@gmail.com
UseSTARTTLS=YES
AuthUser=youraccount
AuthPass=yourpasword
FromLineOverride=YES

In /etc/ssmtp/revaliases:

root:youraccount@gmail.com:smtp.gmail.com:587
mainuser:youraccount@gmail.com:smtp.gmail.com:587

I setup mine for my @archlinux.us account...... works great wink
You can test if it's working by sending your email (to a different account than what you setup for wink  ) by opening a terminal......

echo test | mail -s "testing ssmtp setup" USERNAME@SOMEDOMAIN.COM

USERNAME@SOMEDOMAIN.COM would of course be an email YOU can check wink

That's all folks, it's THAT simple wink

An article on ssmtp
http://www.linux.com/feature/132006

Last edited by crouse (2008-10-08 22:13:25)

Offline

#2 2008-10-08 23:00:28

finferflu
Forum Fellow
From: Manchester, UK
Registered: 2007-06-21
Posts: 1,899
Website

Re: SSMTP with GMail

This would make a nice wiki entry smile


Have you Syued today?
Free music for free people! | Earthlings

"Perfection is achieved, not when there is nothing more to add, but when there is nothing left to take away." -- A. de Saint-Exupery

Offline

#3 2008-10-09 01:14:42

odf
Member
From: Canada / Québec
Registered: 2008-07-17
Posts: 13

Re: SSMTP with GMail

Edit : Oups typo in the password smile Very nice and thank you smile

Last edited by odf (2008-10-09 01:18:09)

Offline

#4 2008-10-09 02:51:54

fukawi2
Ex-Administratorino
From: .vic.au
Registered: 2007-09-28
Posts: 6,217
Website

Re: SSMTP with GMail

finferflu wrote:

This would make a nice wiki entry smile

Yep smile

Offline

#5 2008-11-05 18:37:43

finferflu
Forum Fellow
From: Manchester, UK
Registered: 2007-06-21
Posts: 1,899
Website

Re: SSMTP with GMail

I took the liberty of adding this to the wiki myself. Feel free to edit it and improve it as you wish: http://wiki.archlinux.org/index.php/SSMTP_and_Gmail


Have you Syued today?
Free music for free people! | Earthlings

"Perfection is achieved, not when there is nothing more to add, but when there is nothing left to take away." -- A. de Saint-Exupery

Offline

#6 2008-11-05 23:11:26

Daenyth
Forum Fellow
From: Boston, MA
Registered: 2008-02-24
Posts: 1,244

Re: SSMTP with GMail

Thanks! I wondered how to do this, never knew it was so simple.

Offline

#7 2008-11-06 02:50:58

Ruckus
Member
Registered: 2007-02-17
Posts: 204

Re: SSMTP with GMail

How would you send an email from an alias domain? I have three domain names in my google apps. georgemh.com(Main Email) stayanon.com and wpge.org. I need to send email with the wpge.org domain. The above method only works if you use your main account.

Offline

#8 2008-11-06 02:52:29

fukawi2
Ex-Administratorino
From: .vic.au
Registered: 2007-09-28
Posts: 6,217
Website

Re: SSMTP with GMail

AFAIK, Google rewrite any mail going through their server to use your @gmail.com address. You might need to look into using Postfix instead of sSMTP

Offline

#9 2008-11-09 19:18:19

kgas
Member
From: Qatar
Registered: 2008-11-08
Posts: 718

Re: SSMTP with GMail

Thanks for the nice post. The wiki page contains typo error (ssmpt instead of ssmtp) pl correct it. Also another method is using a text file. For eg create a text file contains the following

To:yourcontact@mailserver.com
From:your_mail address
Subject: Arch linux

Arch linux is a cute and nice distribution.

1. It uses the KISS technology

2. Automatic upgrade thro' pacman

3. Bleeding edge

5. More secure software installation

Give it a Try
------------------
and save this file as test
now (note: one space should be there after subject:)
#ssmtp your_contact_address < test

In this method you can auomate to send mails to your contacts thro' a simple bash script.
Reference: http://tombuntu.com/index.php/2008/10/2 … ith-ssmtp/

Offline

#10 2008-11-09 19:50:22

finferflu
Forum Fellow
From: Manchester, UK
Registered: 2007-06-21
Posts: 1,899
Website

Re: SSMTP with GMail

Thanks kgas, I have updated the wiki page, please correct it if you feel there is any error or innacuracy.

Also notice that you are allowed (and also incouraged) to edit the wiki! smile


Have you Syued today?
Free music for free people! | Earthlings

"Perfection is achieved, not when there is nothing more to add, but when there is nothing left to take away." -- A. de Saint-Exupery

Offline

#11 2008-11-09 20:13:48

haxit
Member
From: /home/haxit
Registered: 2008-03-04
Posts: 1,247
Website

Re: SSMTP with GMail

Looks awesome.


Archi686 User | Old Screenshots | Old .Configs
Vi veri universum vivus vici.

Offline

#12 2008-11-10 00:21:08

crouse
Arch Linux f@h Team Member
From: Iowa - USA
Registered: 2006-08-19
Posts: 907
Website

Re: SSMTP with GMail

finferflu wrote:

I took the liberty of adding this to the wiki myself. Feel free to edit it and improve it as you wish: http://wiki.archlinux.org/index.php/SSMTP_and_Gmail

Thanks finferflu wink

Offline

#13 2008-11-16 12:53:54

Daenyth
Forum Fellow
From: Boston, MA
Registered: 2008-02-24
Posts: 1,244

Re: SSMTP with GMail

Wouldn't this let ANY user on the system send email from your gmail address? Also you should chmod 600 the conf file anyway, plaintext password, etc.

EDIT: I'm silly, I guess the revaliases are so that only your user can send.

Last edited by Daenyth (2008-11-16 12:57:38)

Offline

#14 2008-11-18 11:24:21

Bram
Member
Registered: 2008-05-26
Posts: 2

Re: SSMTP with GMail

I just set this up because I want to send mail with a php script using the gmail smtp servers. It works fine when I use it as root but not as any other user
I have setup the revaliases file (both with my normal user account (bram) and the http user.

when I try to send mail as "bram" using this command:
"echo test | mail -s "test" bram.jessen@gmail.com"

I get this as a return:
"send-mail: 530 5.7.0 Must issue a STARTTLS command first. x37sm3643260ugc.50"


I have setup the ssmtp config file as in the wiki entry
Any ideas on how to fix this?

Last edited by Bram (2008-11-18 11:26:18)

Offline

#15 2008-11-19 14:18:22

Daenyth
Forum Fellow
From: Boston, MA
Registered: 2008-02-24
Posts: 1,244

Re: SSMTP with GMail

How long does it take for the test email to be sent? I tried sending it to myself but I haven't received it yet.

EDIT: It took between 2-5 minutes.

EDIT2: Using this method, how do I attach a file?

Last edited by Daenyth (2008-11-19 15:45:34)

Offline

#16 2008-12-04 00:45:06

Daenyth
Forum Fellow
From: Boston, MA
Registered: 2008-02-24
Posts: 1,244

Re: SSMTP with GMail

How do I get it to send cronjob, etc emails to my email address? In my ssmtp.conf I have

root=myuser@gmail.com

But when I look in gmail at my sent mail, I see that it's addressed "to: root" and not "to: myuser@gmail.com"

Offline

#17 2008-12-04 15:11:56

brisbin33
Member
From: boston, ma
Registered: 2008-07-24
Posts: 1,796
Website

Re: SSMTP with GMail

FWIW, any mutt user can

$ echo "body of email" | mutt -s "subject of email" address@domain.com

or even

$ echo "body of email" | mutt -s "subject of email" -a /file/to/attach.txt address@domain.com

i use it for cronjob/emailing reports/logs to myself smile

also, my mutt is set up with

set sendmail = /usr/bin/msmtp

which has just as simple a gmail setup as ssmtp, and i'm sure

set sendmail = /usr/bin/ssmtp

would work just fine too; as usual more than one way to skin a linux cat.

Last edited by brisbin33 (2008-12-04 19:24:43)

Offline

#18 2008-12-04 18:42:36

Daenyth
Forum Fellow
From: Boston, MA
Registered: 2008-02-24
Posts: 1,244

Re: SSMTP with GMail

Yeah... Except I don't use mutt and don't plan to any time soon.

Offline

#19 2008-12-04 19:16:00

brisbin33
Member
From: boston, ma
Registered: 2008-07-24
Posts: 1,796
Website

Re: SSMTP with GMail

[edited for clarity]

Daenyth wrote:

Yeah... Except I don't use mutt and don't plan to any time soon.

well funny you should say that...

(assuming you've set up ssmtp, if not i still recommend msmtp)

pacman -S mutt
vim ~/.muttrc

now add two lines:

set sendmail = /usr/bin/ssmtp
unset record

then try it:

echo "body" | mutt -s "subject" -a /file/to/send email@address.com

in theory... should do what you want without much fuss.  and if that 2-5 minute delay is ssmtp related try msmtp, the config is simpler (i can give you mine) and my test email arrived immediately.

Last edited by brisbin33 (2008-12-04 19:24:34)

Offline

#20 2009-04-06 08:30:30

imrehg
Member
From: London, UK
Registered: 2008-04-10
Posts: 108
Website

Re: SSMTP with GMail

Hi, I just tried this out and run into a few issues.

If I do the suggested

chmod 600 /etc/ssmtp/ssmtp.conf

then no other user, just root can use that file. Thus every other user returns with error (since they don't know any settings). Maybe should all users have their own ssmtp.conf file?

Also, what is the exact purpose of the /etc/ssmtp/revaliases file? It does not stop any other (not listed) user sending an email from my account, as long as they can read the ssmtp.conf file....

Offline

#21 2009-04-06 20:07:44

JT
Member
Registered: 2009-01-16
Posts: 21

Re: SSMTP with GMail

The same can be done with nail/mailx.

I use nail on my file server to email me important messages using a Gmail account.

The /etc/nail.rc file:

set smtp=smtp.gmail.com:587
set smtp-use-starttls
set ssl-verify=ignore
set ssl-auth=login
set smtp-auth-user=username@gmail.com
set smtp-auth-password=password

To send a message:

echo "...Message..." | nail username@email.com

Enjoy.

Offline

#22 2009-04-06 21:13:34

haxit
Member
From: /home/haxit
Registered: 2008-03-04
Posts: 1,247
Website

Re: SSMTP with GMail

Very, very simple. Very awesome. Will make my own little script for sending emails now, from CLI, when I get back.

Last edited by haxit (2009-04-06 21:13:59)


Archi686 User | Old Screenshots | Old .Configs
Vi veri universum vivus vici.

Offline

#23 2009-04-06 23:40:16

my0pic
Member
From: Melbourne, Australia
Registered: 2008-05-23
Posts: 206

Re: SSMTP with GMail

nail has been replaced with mailx-heirloom for the same functionality.
In my .bashrc I have a couple of functions to take care of sending email from cli that are quite handy

# usage: mailto <address> <subject> <text>
 function mailto()
 {
 echo $3 |mail -s "$2" "$1" &
 }

and for email with an attachment

# send an attachment from CLI
# usage: send <file> <address>
send() 
{
  echo "File sent from archie-bd." | mailx -s "See Attached File" -a $1 $2
}

Offline

#24 2009-04-08 00:27:48

borrell
Member
Registered: 2008-12-02
Posts: 31
Website

Re: SSMTP with GMail

does anyone know how to do the same thing with exim4 and google apps? (Tripwire requires exim4 apparently)

Offline

#25 2009-04-08 17:12:08

Daenyth
Forum Fellow
From: Boston, MA
Registered: 2008-02-24
Posts: 1,244

Re: SSMTP with GMail

Is there any mailing system that will allow me to route transparently via my gmail account without having my gmail password in plaintext somewhere? It's really unacceptable from a security standpoint.

Offline

Board footer

Powered by FluxBB