You are not logged in.
SSMTP with GMail
In arch this is very simple to setup ![]()
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 ![]()
[crouse@VistaCrusher ~]$ pacman -Ss ssmtp
extra/ssmtp 2.62-2
Extremely simple MTA to get mail off the system to a mailhubInstalling 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 ![]()
You can test if it's working by sending your email (to a different account than what you setup for
) by opening a terminal......
echo test | mail -s "testing ssmtp setup" USERNAME@SOMEDOMAIN.COMUSERNAME@SOMEDOMAIN.COM would of course be an email YOU can check ![]()
That's all folks, it's THAT simple ![]()
An article on ssmtp
http://www.linux.com/feature/132006
Last edited by crouse (2008-10-08 22:13:25)
Offline
This would make a nice wiki entry ![]()
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
Edit : Oups typo in the password
Very nice and thank you ![]()
Last edited by odf (2008-10-09 01:18:09)
Offline
This would make a nice wiki entry
Yep ![]()
Are you familiar with our Forum Rules, and How To Ask Questions The Smart Way?
BlueHackers // fscanary // resticctl
Offline
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
Thanks! I wondered how to do this, never knew it was so simple.
[git] | [AURpkgs] | [arch-games]
Offline
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
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
Are you familiar with our Forum Rules, and How To Ask Questions The Smart Way?
BlueHackers // fscanary // resticctl
Offline
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
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! ![]()
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
Looks awesome.
Archi686 User | Old Screenshots | Old .Configs
Vi veri universum vivus vici.
Offline
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 ![]()
Offline
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)
[git] | [AURpkgs] | [arch-games]
Offline
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
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)
[git] | [AURpkgs] | [arch-games]
Offline
How do I get it to send cronjob, etc emails to my email address? In my ssmtp.conf I have
root=myuser@gmail.comBut when I look in gmail at my sent mail, I see that it's addressed "to: root" and not "to: myuser@gmail.com"
[git] | [AURpkgs] | [arch-games]
Offline
FWIW, any mutt user can
$ echo "body of email" | mutt -s "subject of email" address@domain.comor even
$ echo "body of email" | mutt -s "subject of email" -a /file/to/attach.txt address@domain.comi use it for cronjob/emailing reports/logs to myself ![]()
also, my mutt is set up with
set sendmail = /usr/bin/msmtpwhich has just as simple a gmail setup as ssmtp, and i'm sure
set sendmail = /usr/bin/ssmtpwould 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)
//github/
Offline
Yeah... Except I don't use mutt and don't plan to any time soon.
[git] | [AURpkgs] | [arch-games]
Offline
[edited for clarity]
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 ~/.muttrcnow add two lines:
set sendmail = /usr/bin/ssmtp
unset recordthen try it:
echo "body" | mutt -s "subject" -a /file/to/send email@address.comin 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)
//github/
Offline
Hi, I just tried this out and run into a few issues.
If I do the suggested
chmod 600 /etc/ssmtp/ssmtp.confthen 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
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=passwordTo send a message:
echo "...Message..." | nail username@email.comEnjoy.
Offline
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
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
does anyone know how to do the same thing with exim4 and google apps? (Tripwire requires exim4 apparently)
Offline
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.
[git] | [AURpkgs] | [arch-games]
Offline