Posted: Wed May 02, 2007 5:22 am
I'm here again.d11wtq wrote:Does this hang too?
I've tried this code and it's not working (waited one minute and still no signs of life).
A community of PHP developers offering assistance, advice, discussion, and friendship.
http://forums.devnetwork.net/
I'm here again.d11wtq wrote:Does this hang too?
Code: Select all
if (stat("/usr/sbin/sendmail")) {
echo "Stat ok";
}
else {
echo "Stat not ok";
}Code: Select all
<?php
require_once 'lib/Swift/Connection/Sendmail.php';
require_once 'lib/Swift.php';
$sendmail =& new Swift_Connection_Sendmail();
$sendmail->start();
$sendmail->stop();
echo "I got here ok";Yes it works!d11wtq wrote:That's good to hear ~billgoodyear
~garethjax, I just had a thought. Some users have reported (in much older code however) that manually closing the process can solve hangs. Does this work?
Ok, I've already changed this to happen at script shutdown ready for the new release so this should no longer need to be explicitly done. Incidentally it must be a bug with some versions of PHP4 because the problem is something to do with PHP losing contact with the resource handles in the scope of an object by the time the script is shutting down... so I globalised the resources which fixed it in the 3 different PHP4 versions I test with, but clearly not all versions.garethjax wrote:Yes it works!d11wtq wrote:That's good to hear ~billgoodyear
~garethjax, I just had a thought. Some users have reported (in much older code however) that manually closing the process can solve hangs. Does this work?
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]
Im having problems with the new batchmailer.
Specifically, when you used to be able to set the REPLY to and also pass the address as an address object.
Now, when using batchmail, i find that the sender is sent only as an email address, not as the name, and that the replyto is being ignored.
Is the process for passing an Address Object different for the new batch send. BTW, i found i had these two same objects when the first edition of the temporary batchmailer was first written as well.
One other niggly problem, i occasionally run out of memory. Should i just bump up my memory limits or am i doing something wrong?
Here is my code (sanitized for userids etc).Code: Select all
$message =& new Swift_Message($parms["subject"], $parms["message"], "text/html");
$message->setReturnPath("XXXXXX");
$message->headers->set("Reply-To", $parms["replyto"]);
$address = new Swift_Address("XXXXXX", $parms["storename"]); # $parms["replyto"]
if (! is_array($parms["email_address"])) {
$parms["email_address"] = array($parms["email_address"]);
}
$max = count($parms["email_address"]);
$count = 0;
$batchcount = 0;
foreach ($parms["email_address"] as $email_address) {
$count++;
$batchcount++;
if ($count == 0 || $count == 1) {
$recipients =& new Swift_RecipientList();
}
$recipients->addTo($email_address);
if ($count >= $max or $batchcount > 50) {
$smtp =& new Swift_Connection_SMTP("database", 26);
$smtp->setTimeout(90);
$smtp->attachAuthenticator(new Swift_Authenticator_PLAIN());
$smtp->setUsername("XXXXX");
$smtp->setPassword("YYYYY");
$swift =& new Swift($smtp);
$swift->batchSend($message, $recipients, $address);
# echo "\nBatch Transmitted\n" . var_dump($recipients) . "\n";
unset($recipients);
$swift->disconnect();
$count = 0;
}
}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]