- Suppose there is an email template with empty body.
For example,
to: test_to@example.com cc: test_cc@example.com from: test_from@example.com subject: Test Example with empty body
To send this email text, for example, named email_tmpl.txt, through sendmail, simple issue the following command:
sendmail -t < email_tmpl.txt
- Suppose there is an email template with plain text body.
For example,
to: test_to@example.com cc: test_cc@example.com from: test_from@example.com subject: Test Example with plain text body This is an email with plain text body.
To send this email text, for example, named email_tmpl.txt, through sendmail, issue the same command in (1).
- Suppose there is an email template with plain text body as in (2). To send with attachments, e.g. attachments "a.html" and "b.html", issue the following command:
(cat "email_tmpl.txt"; uuencode "a.html" "a.html"; uuencode "b.html" "b.html") | sendmail -t
- Suppose there is an email template with HTML body.
For example,
to: test_to@example.com cc: test_cc@example.com from: test_from@example.com subject: Test Example with HTML body Content-Type: text/html; charset=utf-8 <html> <head></head> <body> This is an email template with <b>HTML</b> body! <body> </html>
To send this email text, use the same command as in (1).
- Suppose there is an email template with HTML body. To send with HTML attachments,
For example,
to: test_to@example.com cc: test_cc@example.com from: test_from@example.com subject: Test Example with HTML body Content-Type: multipart/mixed; boundary="test_example_boundary" --test_example_boundary Content-Type: text/html; charset=utf-8 <html> <head></head> <body> This is an email template with <b>HTML</b> body! <body> </html> --test_example_boundary Content-Type: text/html; charset=utf-8 Content-Disposition: attachment; filename=html_attachment.html <html> <head></head> <body> This is a <b>HTML</b> attachment! <body> </html> --test_example_boundary--
To send this email text, use the same command as in (1).
A blog to log all the findings I have found during my programming life before I forget. ^.^
17 Jan 2013
Send email with attachments in KSH
Subscribe to:
Post Comments (Atom)
1 comment:
Leaving a big THANK YOU for your example!!
Post a Comment