Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
Hi, thanks to the author for this great piece of library. Brilliant works.
I am current writing a simple script, which send an email to all existing member asking to update their profile. Each of the email will contain their existing profile information, which I try to accomplish by utilizing template plug in. However it doesn't works, with no error message or no email send, seems it's terminated when the plug in is called.
Attached is the codes I write, please suggest, thanks.Code: Select all
<?php
require("swift/Swift.php");
require("swift/Swift/Connection/SMTP.php");
// send 50 mails per batch, pause 30 seconds in between batches
$mailer->loadPlugin(new Swift_Plugin_AntiFlood(50,30));
// make the script run until it's finished in the background
set_time_limit(0); ignore_user_abort();
$mailer = new Swift(new Swift_Connection_SMTP('smtp.gmail.com', SWIFT_SECURE_PORT, SWIFT_TLS)) or die("error :: failed to connect to email server");
$mailer->authenticate('username@gmail.com', 'password') or die("error :: failed to authenticate user account");
$email = $user = array();
$query = "select * from member";
$rr = mysql_query($query) or die("Error :: Failed to execute query");
while($rs = mysql_fetch_array($rr)){
$email[] = array($rs['name'], $rs['email']);
$user[] = array(id=>$rs['id'], sc=>$rs['sc'], name=>$rs['name']);
}
$msg = file_get_contents("txt_template/member.php");
$mailer->addPart($msg, 'text/html');
$mailer->loadPlugin(new Swift_Plugin_Template($user));
$mailer->send($email, 'username@gmail.com', 'Please update your contact information');
echo "<pre>";
print_r($mailer->transactions);
echo "</pre>";
$mailer->close();
?>feyd | Please use
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]