Sending mail  Sending mail from command line.

1   Sendmail

sendmail -t << EOF
From: FROMADDRANDNAME
To: TOADDR
Subject: SUBJECT

BODY
EOF

2   Mail

mail -s SUBJECT TOADDR << EOF
BODY
EOF

3   Sending signed mail

This example tries to follow RFC2015. It does not do that perfectly because you should convert from \n to \r\n before the gpg line.

apt-get install mime-construct
mime-construct --subpart --type "text/plain; charset=iso-8859-1" --encoding quoted-printable --file testing.body > testing2.body
gpg --armor --detach-sign --textmode --comment "" testing2.body
mime-construct --multipart 'multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"' --to "ola@opal.dhs.org" --subject "Test signed." --subpart-file testing2.body --type application/pgp-signature --file testing2.body.asc

A better RFC complant version should be this (it is not tested though):

mime-construct --subpart --type "text/plain; charset=iso-8859-1" --encoding quoted-printable --file testing.body > testing2.body
perl -pi -e "s/\n/\r\n/g;" testing2.body
gpg --armor --detach-sign --textmode --comment "" testing2.body
mime-construct --multipart 'multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"' --to "ola@opal.dhs.org" --subject "Test signed." --subpart-file testing2.body --type application/pgp-signature --file testing2.body.asc

4   MIME

apt-get install mime-codecs
qp-encode
qp-decode
base64-encode
base64-decode

5   Nail

Instead of the standart mail(x) command you could install nail instead. It supports from address changing, attachments, etc.

apt-get install nail

6   More

Martin F Krafft sent me a mail with a Makefile that takes an FRC822 message and sign it to produce .msg. I have added it here for completeness.


Copyright © 2005 Ola Lundqvist
Last updated: Thu Jan 20 07:48:59 2005 (CET).
Author: Ola Lundqvist
URL: http://www.opal.dhs.org/docs/sending-mail/index.oml
Administrator: webmaster@inguza.net