Ads by Google

Showing posts with label attachments. Show all posts
Showing posts with label attachments. Show all posts

Sunday, January 15, 2012

Sending Emails with Attachments from the Command Line Revisited

Previously I had posted about trying to send attachment emails from the command line here and here.  But the hitch was, every time I changed computers(which while infrequent) I still had to download and compile mpack and install it every time.

On a whim, when I asked on the cygwin mailing list, I was asked to try the Email package.  And I have to report it works beautifully.  It needs an MTA to connect to the mail server, for which there is msmtp and is part of the Cygwin packaged utilities already.   That sort of solves my portability issue.

Configuring Email was simple.  Edit the email.conf file with the following minimum details and you're set.


############################################################
SENDMAIL_BIN = '/usr/sbin/msmtp -t'
MY_NAME  = 'Sivaram '
MY_EMAIL = 'nnsivaram.nnet@gmail.com'
#REPLY_TO = ''
USE_TLS = 'true'
TEMP_DIR = '/tmp'
SMTP_AUTH = 'LOGIN'
SMTP_AUTH_USER = ' nnsivaram.nnet

And you call it in the shell script as follows


    echo "Mailing... $mailid with $attachfile"


    /usr/bin/email  -s "Mailed report on `date`" -a $attachfile  $mailid < $mbody
    echo "email Return code is $?"


Tuesday, May 27, 2008

Email attachments and Gnus

When you receive files in your email and they're embedded in the mail message, a quick way to save them is to hit K o. With a numerical prefix, it will save the nth inline or MIME attachment.

If the file is large and you want to strip it from the mail message, K O will do the trick. Again, deleting the same can be done via K d, because some mail clients will stupidly resend the attachments when replying without stripping it first as a default behaviour.

More useful commands can be found here.