Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- require_once 'path/to/SwiftMailer/lib/swift_required.php';
- $transport = Swift_MailTransport::newInstance();
- # Create the Mailer using your created Transport
- $mailer = Swift_Mailer::newInstance($transport);
- # Create the message
- $msg = Swift_Message::newInstance();
- # Give the message a subject
- $msg->setSubject($_POST['subject']);
- # Set the From address with an associative array
- $msg->setFrom(array($_POST['sender_email'] => $_POST['sender_name']));
- # Give it a body
- $msg->setBody($_POST['message'], 'text/html');
- $failedRecipients = array();
- $numSent = 0;
- $to = array(
- 'recipient_1@gmail.com',
- 'recipient_2@yahoo.com' => 'Recipient 2',
- 'recipient_3@hotmail.com',
- 'recipient_4@gmail.com' => 'Recipient 4',
- 'recipient_5@yahoo.com'
- );
- foreach ($to as $address => $name) {
- if (is_int($address)) {
- $msg->setTo($name);
- } else {
- $msg->setTo(array($address => $name));
- }
- $numSent += $mailer->send($msg, $failedRecipients);
- }
- echo $numSent > 0 ? 'SUCCESS' : 'FAILURE';
- ?>
- $msg->setBody($_POST['message'], 'text/html');
- $msg->setBody(stripslashes($_POST['message']), 'text/html');
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement