July 16, 2014 606 Views 1 Comment

SpeedyMailer Embeddable PHP Mass Mailing App


Using Swiftmailer, Tinymce and Semantic UI framework to create an embeddable, feature rich mass mailing app. Speedy Mailer adds a sleek easy to use User Interface to swiftmailer.

Speedymailer Demo


The Interface

Speedymailer Class (speedy.class.php)

The Speedymailer class uses the PHP Swiftmailer library to send emails.

require_once 'swiftmailer/lib/swift_required.php';

class SpeedyMailer{
function sendMail($recipientArr, $ccAddress=null, $bccAddress=null, $subject, $body, $fromAddress){
if (!is_array($recipientArr)) {
echo "Recipient Invalid or Null";

echo "From Address Invalid or Null";

// Create the mail transport configuration
$transport = Swift_MailTransport::newInstance();

// Create an instance of the plugin and register it
$plugin = new Swift_Plugins_DecoratorPlugin($replacements);
$mailer = Swift_Mailer::newInstance($transport);

// To use the ArrayLogger
$logger = new Swift_Plugins_Loggers_ArrayLogger();
$mailer->registerPlugin(new Swift_Plugins_LoggerPlugin($logger));

// Create the message
$message = Swift_Message::newInstance();
$message->setBody($body, "text/html");

// Use AntiFlood to re-connect after xx emails And specify a time in seconds to pause for (30 secs)
$mailer->registerPlugin(new Swift_Plugins_AntiFloodPlugin(30, 100));

// Custom Logs Array
$logsArr = array();

// Send the email
foreach($recipientArr as $user) {
$numSent += $mailer->send($message, $failures);
$logsArr ['Failed'][] = 'Failed to send email to '.$user. " | ".$logger->dump();
$logsArr ['Success'][] = 'Success sending to '.$user;

// Show Count Of Messages Sent/Failed
printf("Sent %d messages\n", $numSent);
printf("Failed %d messages\n", $failures);

// Dump the log contents

// Store Logs in DB
storeMailLogs($logsArr, $fromAddress, $subject, $body);

Designing the Front-end using Semantic UI Framework

Semantic is a Bootstrap like tag-agnostic UI components library that uses natural language conventions to make development more intuitive.

<div id="tabs_container">
<ul id="tabs">
<li class="active mailTab"><a class="icon_email" href="#tab1"><i class="mail icon"></i>SEND EMAIL</a></li>
<li class="logTab"><a class="icon_logs" href="#tab2"><i class="time icon"></i>LOGS</a></li>
<div id="emailWidget">
<div id="tab1" class="tab_content" style="display: block;">

<div class="ui form">
<div class="ui fluid input field">
<input name="email-subject" placeholder="Subject..." type="text">

<p class="heading">Recipient(s)</p>
<div class="content">
<div class="ui fluid input field">
<input name="recipients" placeholder="Recipient..." type="text">

<p class="heading">Sender Information </p>
<div class="content">
<div class="ui fluid input field">
<input name="from-name" placeholder="From Name..." type="text">
<div class="ui fluid input field">
<input name="from-email" placeholder="From Email..." type="text">

<p class="heading">Compose Message</p>
<div class="content default_expanded" style="display:block!important;">
<textarea name="msg-body" id="wysiwyg"></textarea>

<!-- // Buttons -->
<div class="ui labeled black icon submit button">
<i class="forward mail icon"></i>
Send Email
<div class="ui right labeled black icon button resetForm">
<i class="right eraser icon"></i>
Clear All
<!-- // Buttons -->

<div id="tab2" class="tab_content">

  • John

    I am always trying to find a good newsletter type of system for my websites. The demo and tutorial you have here is just enough to give Speedymailer a try. Thanks!