SpeedyMailer Embeddable PHP Mass Mailing App

- - Kode

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

DEMO
DOWNLOAD

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";
return;
}

if(!$fromAddress){
echo "From Address Invalid or Null";
return;
}

// 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);
$mailer->registerPlugin($plugin);

// 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->setSubject($subject);
$message->setBody($body, "text/html");
$message->setFrom($fromAddress);

// 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) {
$message->setTo($user);
$numSent += $mailer->send($message, $failures);
if($failures){
$logsArr ['Failed'][] = 'Failed to send email to '.$user. " | ".$logger->dump();
}else{
$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
print_r($logsArr);

// 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>
</ul>
</div>
<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">
</div>

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

<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>
<div class="ui fluid input field">
<input name="from-email" placeholder="From Email..." type="text">
</div>
</div>

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

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

<div id="tab2" class="tab_content">
<p>...</p>
</div>
</div>

DEMO
DOWNLOAD


Post Tags:
Join the Newsletter

Sign up for our personalized daily newsletter

Kodesmart

#1 GUIDE TO DRUPAL, WORDPRESS, CSS AND CUSTOM CODING | BEGINNER TO PRO

  • 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!