Sending HTML mail using a shell script

First you need to compose the message. The bare minimum is composed of these two headers: MIME-Version: 1.0 Content-Type: text/html … and the appropriate message body: <!DOCTYPE HTML PUBLIC “-//W3C//DTD HTML 4.01 Transitional//EN” “http://www.w3.org/TR/html4/loose.dtd”> <html> <head><title></title> </head> <body> <p>Hello, world!</p> </body> </html> Once you have it, you can pass the appropriate information to the mail … Read more

Send SMTP email using System.Net.Mail via Exchange Online (Office 365)

Fixed a few typos in the working code above: MailMessage msg = new MailMessage(); msg.To.Add(new MailAddress(“someone@somedomain.com”, “SomeOne”)); msg.From = new MailAddress(“you@yourdomain.com”, “You”); msg.Subject = “This is a Test Mail”; msg.Body = “This is a test message using Exchange OnLine”; msg.IsBodyHtml = true; SmtpClient client = new SmtpClient(); client.UseDefaultCredentials = false; client.Credentials = new System.Net.NetworkCredential(“your user … Read more

Sending mail via sendmail from python

Header injection isn’t a factor in how you send the mail, it’s a factor in how you construct the mail. Check the email package, construct the mail with that, serialise it, and send it to /usr/sbin/sendmail using the subprocess module: import sys from email.mime.text import MIMEText from subprocess import Popen, PIPE msg = MIMEText(“Here is … Read more