Difference between revisions of "Sendmail to send mail"

From Noah.org
Jump to navigationJump to search
 
Line 1: Line 1:
 
[[Category:Engineering]]
 
[[Category:Engineering]]
 
[[Category:Mail]]
 
[[Category:Mail]]
 +
== 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:
 
Create a message file:
 
<pre>
 
<pre>

Latest revision as of 13:56, 1 October 2008

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