sendMail

Sends an e-mail using the given settings.

The mail parameter must point to a valid Mail object and should define at least the headers "To", "From", Sender" and "Subject".

Valid headers can be found at http://tools.ietf.org/html/rfc4021

@safe
void
sendMail

Examples

The following example demonstrates the complete construction of a valid e-mail object with UTF-8 encoding. The Date header, as demonstrated, must be converted with the local timezone using the toRFC822DateTimeString function.

import vibe.inet.message;
import std.datetime;
void testSmtp(string host, ushort port){
	Mail email = new Mail;
	email.headers["Date"] = Clock.currTime(PosixTimeZone.getTimeZone("America/New_York")).toRFC822DateTimeString(); // uses UFCS
	email.headers["Sender"] = "Domain.com Contact Form <no-reply@domain.com>";
	email.headers["From"] = "John Doe <joe@doe.com>";
	email.headers["To"] = "Customer Support <support@domain.com>";
	email.headers["Subject"] = "My subject";
	email.headers["Content-Type"] = "text/plain;charset=utf-8";
	email.bodyText = "This message can contain utf-8 [κόσμε], and\nwill be displayed properly in mail clients with \\n line endings.";

	auto smtpSettings = new SMTPClientSettings(host, port);
	sendMail(smtpSettings, email);
}
// testSmtp("localhost", 25);

Meta