Command line SMTP client with support of SASL authentication

1

Mutt (with compiled SMTP support) while sending a message can display the progress of the operation, but it only does that in the interactive mode. If one tries to run Mutt in the batch mode:

% mutt -s 'test #1' -a huge_file.tar.gz -- joe@example.com
SSL connection using TLSv1/SSLv3 (RC4-MD5)

he will not see progress updates, which is inconvenient for sending very big files.

My question is: is there any SMTP command line client that have an ability to send message through GMail smtp server and display a progress bar (or something similar) to user?

Thanks in advance.

Alexander Gromnitsky

Posted 2009-08-21T00:44:23.330

Reputation: 229

Answers

2

I believe swaks is exactly what you're looking for.

LiraNuna

Posted 2009-08-21T00:44:23.330

Reputation: 1 664

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

1

after rereading the question and getting the essential part (which should be highlighted) i think i would do this (since i found no such solution in existing smtp-clients):

use the source of msmtp, in its 'smtp.c' there is 'smtp_send_mail()' where the actual sending happens. i would patch that file to print out how much of the mail is sent. maybe as an option, maybe to react on a signal (like 'kill -USR1 ') ...

akira

Posted 2009-08-21T00:44:23.330

Reputation: 52 754

0

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.

jtimberman

Posted 2009-08-21T00:44:23.330

Reputation: 20 109

Thanks for the answer, but my question was not how to setup MTA (I'm quite happy with sendmail+cyrus-sasl2). I just want a simple command line util that can send mail (without touching my MTA) in batch mode like mutt and display a sort of progress bar like wget. – Alexander Gromnitsky – 2009-08-21T05:10:41.143