Posts Tagged mail

ssmtp and gmail or google apps

Unix systems often needs a local mailer, but configuring and maintaining a mailer on each system is a timeloss.
You might have a gmail or google apps account. If it’s the case, you can easily configure a mailer on your systems which uses your gmail or google apps. To do so, I’ve used ssmtp and put this in /etc/ssmtp/ssmtp.conf:

root=postmaster
mailhub=smtp.gmail.com:587
AuthUser=your-mail@yourdomain.com
AuthPass=aStr4angeP45s
UseSTARTTLS=YES
hostname=the-hostname

That’s it, simple, effective, working …
To improve the things, maybe, we can use an IP address of the smtp server, so that if our DNS server doesn’t work, we still have mail on the system, but this has a drawback, if the server for which you gave an ip address changes or temporarly doesn’t work, you don’t have mail anymore.
ssmtp doesn’t seem to be able to have several mailhubs !

Comments (4)

Validate email addresses

You probably never tried to validate email addresses, I did, and it doesn’t seem to be hard, but it is (sorry if you also did 😉 )!
I was searching for a regexp, and if you search one you will find tone of them, but you don’t know which one to choose. Some are very long, some are too restictive (doesn’t handle new TLDs or handle only TLDs with three letters), some are RFC-822 compliant but they seems complicated, and I wonder if all addresses are RFC 822 compliant (It’s pretty often that RFC are not respected) … Also, it’s not because the format of the email address is valid, that that mail exists. The best and easy solution I came with, which is not the full solution, is to use the Email::Valid perl module like this:

#!/bin/perl
Read the rest of this entry »

Leave a Comment