Hi this was discussed a little in another thread:
http://processwire.c...age__hl__mailer
I actually use templates and Mandrill to send some of my transactional emails such as welcome emails and confirmations. It's relatively easy to do this using SMTP. Here's an example:
<?php
require_once "Mail.php";
require_once "Mail/mime.php";
$email = new Page();
$email->template = $templates->get("email-template");
$email->somePageVariable = "example";
$email->setOutputFormatting(true);
$body = $email->render();
// Header info
$from = "<info@yoursite.com>";
$to = "<user@name.com>";
$subject = "Thank you for registering!";
// Send via Mandrill
$host = "ssl://smtp.mandrillapp.com";
$port = "465";
$username = "info@yoursite.com"; // Your mandrill user name
$password = "secretKey"; // Your mandrill API key
$headers = array (
'From' => $from,
'To' => $to,
'Subject' => $subject,
);
$smtp = Mail::factory('smtp', array (
'host' => $host,
'port' => $port,
'auth' => true,
'username' => $username,
'password' => $password
));
$message = new Mail_mime();
$message->setHTMLBody($body);
$mail = $smtp->send($to, $message->headers($headers), $message->get());
if (PEAR::isError($mail)) {
echo($mail->getMessage() . "\n");
} else {
echo("Message successfully sent!\n");
}
Because the template can pull in content anywhere from your site, you can easily make templates for upcoming events, latest news, etc.
For inlining CSS, premailer now offers an API. I think it's best to use netcarver's tag parser for user-specific details when bulk mailing. You could render these in the template and pass in the user ID to that, but then you'd have to inline the CSS after rendering each and every email. It should be possible to avoid this by rendering the template, sending to premailer, and then looping through the recipients replacing the first_name, surname etc. I've not tried this out yet though.
Stephen