Swift_RecipientList() addCc
Posted: Thu Oct 11, 2007 3:24 am
feyd | Please use
to set the addresses.
here is the code:
$issent will return 2 in my case. That should mean there are 2 mails sent in each loop. But actually I just receive one.
The problem occures on both Unix and Windows box. PHP 5.1.2
Any help here?
Thanks a lot,
Christoph
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]
Hi all,
as swift is really easy to use, I am quite sure that there is an Error in my Code. Lets see:
In my test script I want to send 5 Mails to 2 different addresses. I use theCode: Select all
$recipients = new Swift_RecipientList();
$recipients->addTo("xx@xxx.com", "You");
$recipients->addCc("xxx@xx.ch");here is the code:
Code: Select all
require_once "lib/Swift.php";
require_once "lib/Swift/Connection/SMTP.php";
//Start Swift
try {
$smtp = new Swift_Connection_SMTP("mail4.ccc.ch", 25);
$smtp->setUsername("ItsMe");
$smtp->setpassword("getIt");
$swift =& new Swift($smtp);
for ($counter = 0; $counter <= 5; $counter++) {
//Create the message
$subject = "No".$counter." after ".$used_time;
$body = "My body";
$message = new Swift_Message($subject, $body);
$message->setCharset("utf-8");
//recipients
$recipients = new Swift_RecipientList();
$recipients->addTo("xx@xxx.com", "You");
$recipients->addCc("xxx@xx.ch");
//$recipients->addBcc("", "");
$sender = new Swift_Address("testmail@xx.com", "Testmail");
//Now check if Swift actually sends it
$issent = $swift->send($message, $recipients, $sender);
// $issent will give the number of sucessfull recipients
if ($issent) {
echo "Sent $counter number sent: $issent <br>";
}
else {
echo "Failed<br>";
}
$end_time = time();
$used_time = $end_time - $time_start;
} // for
}
catch (Swift_ConnectionException $e) {
$sendMailError = $e->getMessage();
} catch (Swift_Message_MimeException $e) {
$sendMailError = $e->getMessage();
}The problem occures on both Unix and Windows box. PHP 5.1.2
Any help here?
Thanks a lot,
Christoph
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]