I would set up Postfix as my local MTA with SASL enabled.
On an Ubuntu 9.04 example system, install the postfix, libsasl2-2 and ca-certificates packages. Create/modify the following Postfix config files.
/etc/postfix/main.cf:
biff = no
append_dot_mydomain = no
smtpd_tls_cert_file=/etc/ssl/certs/ssl-cert-snakeoil.pem
smtpd_tls_key_file=/etc/ssl/private/ssl-cert-snakeoil.key
smtpd_use_tls=yes
smtpd_tls_session_cache_database = btree:${queue_directory}/smtpd_scache
smtp_tls_session_cache_database = btree:${queue_directory}/smtp_scache
smtp_sasl_auth_enable = yes
smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd
smtp_sasl_security_options = noanonymous
smtp_tls_CAfile = /etc/postfix/cacert.pem
smtp_use_tls = yes
myhostname = linuxbox.int.example.com
mydomain = example.com
myorigin = $mydomain
smtpd_banner = $myhostname ESMTP $mail_name
alias_maps = hash:/etc/aliases
alias_database = hash:/etc/aliases
mydestination = linuxbox.int.example.com, linuxbox, localhost.localdomain, localhost
relayhost = [mail.google.com]:587
mynetworks = 127.0.0.0/8
inet_interfaces = loopback-only
mailbox_size_limit = 0
recipient_delimiter = +
All other values can be defaults, in fact many of these are, of note are the smtp_* at the beginning. Change the hostname and domain for your environment.
/etc/postfix/sasl_passwd:
[mail.google.com]:587 gmail_username:gmail-password
Replace mail.google.com with whatever Google's SMTP server is and the gmail_username and gmail-password with the proper values.
Run postmap and restart postfix:
sudo postmap /etc/postfix/sasl_passwd
sudo /etc/init.d/postfix restart
Now when you send mail on your system, it will use Postfix as the local MTA and automatically authenticate with SASL.
It works with gmail but cannot display any decent progress bar. (-stl option is not very helpful.) – Alexander Gromnitsky – 2009-09-18T10:36:02.223
Came to this thread for a decent shell script for SMTP transaction. swaks fits the bill perfectly. Thanks! – Rajkumar S – 2012-04-26T14:27:03.213