Tuesday, July 27, 2010

msmtp - simple smtp client

If you need to send mails from some UNIX box where mail transport don't work (MTA not configured properly), you may use this nice tool:
http://msmtp.sourceforge.net
I've compiled it for Linux and AIX 6.1 (with gcc compiler) without any issue.
Some samples of usage:
# echo "Test" | msmtp --host=smtp.server.org -f root@oracle.com user@some.domain.net
will send mail with no subject and "Test" in mail body.
Otherwise you may construct text file like this and then redirect it to msmtp
# cat mail.txt
From: root@oracle.com
To: user@some.domain.net
Subject: Very important message!!!

Hi! How are you?
#
# msmtp --host=smtp.server.org -f root@oracle.com user@some.domain.net <>> mail.txt
it will be mail with attachment:
# msmtp --host=smtp.server.org -f root@oracle.com user@some.domain.net < style="font-weight: bold;">
UPDATE:
There is some strange behavior on AIX: attachments shown as is (BASE64 code) in mail body not as attachments!
This fix works for me:
# msmtp --host=smtp.server.org -f root@oracle.com user@some.domain.net <<> From: root@oracle.com
> To: user@some.domain.net
> Subject: Very important message!!!
>
> See this attachment:
> $(uuencode install.log.gz install.log.gz)
>
> EOF
#

No comments: