|
mail_queue problem
Hi
I wrote a mailer to send newsletters using MAIL_QUEUE. Actually; with all my testings it worked fine. I put hundreds of HTML-mails in the mail queue database using mail_queue->put(...)
Now I wanted to send a newsletter to over 5000 people and it doesn't work. It first sends the mail without problems to several people and then it starts sending wrong information to sendmail; while the information in the mails is nearly the same. I use an MD5 hashed key for people to unsubscribe.
The error I got is:
------------>
sendmail: fatal: Recipient addresses must be specified on the command line or via the -t option
postdrop: warning: stdin: unexpected EOF in data, record type 78 length 71
postdrop: fatal: uid=0: malformed input
Notice: Error in sending mail: sendmail returned error code 64 in /usr/share/php/PEAR.php on line 846
------------->
So if I send the same newsletter to a small amount of people; there is no problem. And to a big amount... it goes wrong.
I looked into the database; did variable dumps etc. But I can't find it. I have the database with mails that didn't go out.
Anybody has a clue how I can debug this? I'm looking into this for days.
detail: I call this programm command line; using crontab
php Code:
Original
- php Code |
|
|
|
... deleted some init stuff $newsletter_id = 0; $newsletterData = array(); // maillijst = array with mail information foreach ($maillijstData as $maillijst) { // if a new newsletter is in the list if ($maillijst['newsletter_id'] <> $newsletter_id) { $newsletterData = $xdbHandler->getNewsletter($maillijst['customer_id'], $maillijst['newsletter_id']); $newsletter_id = $newsletterData[0]['newsletter_id']; // do some newsletter things once $newsletterData[0]['html_version'] = lib::genereerHeader($newsletterData[0]['html_version']); // opschonen newsletter xms tags $newsletterData[0]['html_version'] = str_replace('<xms:template>', '', $newsletterData[0]['html_version']); $newsletterData[0]['html_version'] = str_replace('<xms:/template>', '', $newsletterData[0]['html_version']); $newsletterData[0]['html_version'] = str_replace('<xms:body>', '', $newsletterData[0]['html_version']); $newsletterData[0]['html_version'] = str_replace('<xms:/body>', '', $newsletterData[0]['html_version']); $newsletterData[0]['html_version'] = str_replace('<xms:text>', '', $newsletterData[0]['html_version']); $newsletterData[0]['html_version'] = str_replace('<xms:/text>', '', $newsletterData[0]['html_version']); $newsletterData[0]['html_version'] = str_replace('<xms:image>', '', $newsletterData[0]['html_version']); $newsletterData[0]['html_version'] = str_replace('<xms:/image>', '', $newsletterData[0]['html_version']); } $from = $maillijst['from_name'].' <'.$maillijst['from_email'].'>'; $to = $maillijst['firstname'].' '. $maillijst['prefixlastname'] . ' ' . $maillijst['lastname'] . '<'.$maillijst['email'].'>'; #$from = $maillijst['from_email']; #$to = $maillijst['email']; $subject = $newsletterData[0]['subject']; $hdrs = array( 'From' => $from, 'To' => $to, 'Subject' => $subject ); $xdbHandler->setNewsletterListSendDate($maillijst); $crlf = "n"; $mime =& new Mail_mime($crlf); if (strlen($newsletterData[0]['text_version']) > 0) { $mime->setTXTBody($newsletterData[0]['text_version']); } if (strlen($newsletterData[0]['html_version']) > 0) { $html_bericht = $newsletterData[0]['html_version']; // converteer mailing $html_bericht = str_replace('[unique_user]', $maillijst['unique_id'], $html_bericht); $html_bericht = str_replace('[firstname]', $maillijst['firstname'], $html_bericht); $html_bericht = str_replace('[prefixlastname]', $maillijst['prefixlastname'], $html_bericht); $html_bericht = str_replace('[lastname]', $maillijst['lastname'], $html_bericht); $html_bericht = str_replace('[email]', $maillijst['email'], $html_bericht); $html_bericht = str_replace('[from_name]', $maillijst['from_name'], $html_bericht); $html_bericht = str_replace('[from_email]', $maillijst['from_email'], $html_bericht); switch ($maillijst['gender']) { case 'm' : $aanhef = ' heer '; break; case 'f' : $aanhef = ' mevrouw '; break; default : $aanhef = ' heer / mevrouw '; break; } $html_bericht = str_replace('[aanhef]', $aanhef, $html_bericht); $html_bericht = str_ireplace('[euro]','€',$html_bericht); $mime->setHTMLBody($html_bericht); } $body = $mime->get(); $hdrs = $mime->headers($hdrs); /* Put message to queue */ $mail_queue->put( $from, $to, $hdrs, $body ); } /* How many mails could we send each time the script is called */ $max_amount_mails = 50; /* we use the db_options and mail_options from the config again */ #$mail_queue =& new Mail_Queue($db_options, $mail_options); /* really sending the messages */ $mail_queue->sendMailsInQueue($max_amount_mails); // end of programm
This programm is called every minute. So at one time $maillijst is full of information... and all the other time not.
So it fills up the mail_queue... and then starts sending 50 mails at a time.
|