Sendmail to send mail

From Noah.org
Jump to: navigation, search

mail delivery test with sendmail

This shows how to send a message from the commandline using sendmail. See also SMTP_test.

Create a message file:

Subject: test
To: username@example.com

This is a test message.

Use sendmail to send the message:

sendmail -t < message

In a script you could do something like this:

#!/bin/sh
# This gives an example of sending an HTML message.
#
(
echo "From: myuser@example.com"
echo "To: user@example.net"
echo "MIME-Version: 1.0"
echo "Content-Type: multipart/mixed;"
echo ' boundary="BOUNDARY"'
echo "Subject: Test Message"
echo ""
echo "This is a MIME-encapsulated message"
echo "--BOUNDARY"
echo "Content-Type: text/plain"
echo ""
echo "This is what someone would see without an HTML capable mail client."
echo ""
echo "--BOUNDARY"
echo "Content-Type: text/html"
echo ""
echo "<html>
<body bgcolor='black'>
<blockquote><font color='green'>GREEN</font> <font color='white'>WHITE</font> <font color='red'>RED</font></blockquote>
</body>
</html>"
echo "--BOUNDARY"
) | sendmail -t