Question

I've been given the task of optimizing HTML emails for different email/webmail clients. I used to test the HTML file by doing a trick in Outlook Express, to make it send the raw HTML, but Microsoft seems to have stopped supplying Outlook Express now (I think "Live Mail" is supposed to replace it).

So my question is, is there a simple, quick way to send HTML emails? Maybe even a freeware program that does the job?

Was it helpful?

Solution

A Test Mail Server Tool can help with that -if you just need to receive and view any emails sent by your application.

OTHER TIPS

Puts Mail is the best bet these days. Check out an answer to a similar question by the creator of Puts Mail.

I would use python, here at the bottom is an example how to create a HTML email with a text default: http://docs.python.org/library/email-examples.html you can parameterize this, encapsulate in functions, read content from files, etc. (make sure, that you set localhost in "s = smtplib.SMTP('localhost') " to your smtp server)

If you are just looking to test whether an HTML email displays properly in various clients, I would use sendmail.exe (windows only).

You can save a .html file and pipe it into that program on the command-line as the email content. There are command line options for from/to/subject/server, etc.

This would allow you to rapidly send and re-send emails by just editing the .html file and running the command-line again. No programming required.

Edit: there is a similar command-line tool for Linux with the same name.

If you're on a Mac you can send HTML email super quickly using Safari and Mail. I blogged about the details at the link below, but basically you just view your HTML file in Safari and select File > Mail Contents of This Page.

http://www.ravelrumba.com/blog/send-html-email-with-safari-mail-for-fast-testing/

I believe you can send html emails from Mozilla's Thunderbird email client.

http://www.mozillamessaging.com/en-US/thunderbird/

This is what I used to send test emails. Or I guess you could use your email provider too.

I would not even go with any language ...

I would stop at MailChimp and set up a free account (max of 500 subscribers and 3000 sends per month) ... 3000 sends is enough to test right? :)

It has all the tools you need to send emails professionally (and maybe set up an account to your client/friend so they/he can use MailChimp in their Newsletters)

while you're at it, see their resources page as well the perfect tool to know what can we use in Newsletters using CampaignMonitor own Guide to CSS support in email clients

hope it helps

If you are running .NET and you have a Gmail account this is one easy way

using System.Net;
using System.Net.Mail;

var fromAddress = new MailAddress("from@gmail.com", "From Name");
var toAddress = new MailAddress("to@example.com", "To Name");
const string fromPassword = "fromPassword";
const string subject = "Subject";
const string body = "Body";

var smtp = new SmtpClient
           {
               Host = "smtp.gmail.com",
               Port = 587,
               EnableSsl = true,
               DeliveryMethod = SmtpDeliveryMethod.Network,
               UseDefaultCredentials = false,
               Credentials = new NetworkCredential(fromAddress.Address, fromPassword)
           };
using (var message = new MailMessage(fromAddress, toAddress)
                     {
                         Subject = subject,
                         Body = body
                     })
{
    smtp.Send(message);
}

see Sending email in .NET through Gmail for more details

Ruby variant:

require "mail"

options = {
  :address              => "smtp.gmail.com",
  :port                 => 587,
  :domain               => "smtp.gmail.com",
  :user_name            => "me@gmail.com",
  :password             => "password",
  :enable_starttls_auto => true,
  :authentication       => :plain,
}

Mail.defaults do
  delivery_method :smtp, options
end

mail = Mail.new do
  to      "me@gmail.com"
  from    "Me Me me@gmail.com"
  subject "test email"

  html_part do
    content_type "text/html; charset=UTF-8"
    body File.read("index.html")
  end
end

mail.deliver

Do not forget to enable access from https://www.google.com/settings/security/lesssecureapps

I send HTML email (often in bulk) using PHPMailer. It has worked great for me.

Also you can use PowerShell

A Windows-only free solution where you typically don't have to install anything special is to use ASP or WSH. I opt for JScript instead of VBScript:

function sendHtml(recipients, subject, html) {
    var mail = Server.CreateObject("CDO.Message");

    mail.From = "Tester <tester@example.com>";
    mail.Subject = subject;
    mail.To = recipients.join(";");
    mail.HTMLBody = html;

    // Do the following if you want to directly use a specific SMTP server
    mail.Configuration.Fields.Item(
        "http://schemas.microsoft.com/cdo/configuration/sendusing") = 2;
    mail.Configuration.Fields.Item(
        "http://schemas.microsoft.com/cdo/configuration/smtpserver")
        = "smtp.example.com";
    mail.Configuration.Fields.Item(
        "http://schemas.microsoft.com/cdo/configuration/smtpserverport")
        = 25;
    mail.Configuration.Fields.Update();

    mail.Send();
}

Note: However, your HTML may end up getting slightly reformatted with this approach.

Very late to the conversation, but here is the quickest method (although far from best practice) to send a html email:

View your rendered html in a web browser (like a web page), then ctrl+a select the entire page then ctrl+c copy and ctrl+v paste that rendered html result into the body of your email. Doesn't get any easier than that...

Just note that your images need to be hosted if you want the recipient to see them.

function sendHtml(recipients, subject, html) {
var mail = Server.CreateObject("CDO.Message");

mail.From = "Tester <tester@example.com>";
mail.Subject = subject;
mail.To = recipients.join(";");
mail.HTMLBody = html;

// Do the following if you want to directly use a specific SMTP server
mail.Configuration.Fields.Item(
    "http://schemas.microsoft.com/cdo/configuration/sendusing") = 2;
mail.Configuration.Fields.Item(
    "http://schemas.microsoft.com/cdo/configuration/smtpserver")
    = "smtp.example.com";
mail.Configuration.Fields.Item(
    "http://schemas.microsoft.com/cdo/configuration/smtpserverport")
    = 25;
mail.Configuration.Fields.Update();

mail.Send();
}

Maybe you can use System.Net.Mail in .NET?

You can read from an email template and assing to a MailMessage body.

To send email

            System.Net.Mail.MailMessage msg = CreateMailMessage();

            SmtpClient sc = new SmtpClient();
            sc.Host = ConfigurationManager.AppSettings["SMTPServer"];
            sc.Port = 0x19;
            sc.UseDefaultCredentials = true;

            sc.Send(msg);
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top