I'm very much enjoying learning and using SwiftMailer. I have one (hopefully basic) question. I'd like to make sure that I'm utilizing SwiftMailer in the best and most efficient manner. I have an Array that is $_POST'd from a form where multiple email addresses can be passed through. This is what I'm currently using as my script, which works fine, by the way:
Code: Select all
<?
echo "Please be patient...<br>";
$html = stripslashes($_POST["bpost"]);
$subj = stripslashes($_POST["subjectpost"]);
$address=$_POST['address'];
$fullname=$_POST['fullname'];
require_once "../lib/Swift.php";
require_once "../lib/Swift/Connection/SMTP.php";
require_once "../lib/Swift/Plugin/Decorator.php";
$swift =& new Swift(new Swift_Connection_SMTP("smtphost.net"));
$names = $_POST['players'];
foreach ($names as $n) {
$bod = $html;
$bod .= "<br>Your email is address is: $n'>";
$message =& new Swift_Message($subj, $bod, "text/html");
$recipients =& new Swift_RecipientList();
$recipients->addTo($n);
if ($swift->send($message, $recipients, new Swift_Address($address, $fullname))) echo "Mail sent to $n!<br>";
else echo "Failed";
}
$swift->disconnect();
?>
Thanks, looking forward to the comments and assistance!