Illasera Posted August 19, 2011 Share Posted August 19, 2011 I am trying to send mail (Using Zend mail API and a valid SMTP server) to send over 800 clients, but the process seems to be aborted after ~25 mailsAnyone have any idea why? The function simply go through the SQL database and send mails untill no more clients left to query.Thanks in advance. Link to comment Share on other sites More sharing options...
justsomeguy Posted August 19, 2011 Share Posted August 19, 2011 The script might be timing out, depending how long it takes to send each mail. I use cron jobs to send batches of mail. A cron job doesn't time out, but you'll need to check to make sure there's not already another job running so you don't send duplicate mails. Link to comment Share on other sites More sharing options...
Illasera Posted August 19, 2011 Author Share Posted August 19, 2011 How do i find out the script isn`t timing out, I am unable to invoke any errors, and the script doesnt seems to reach the end, How do i verify it with my own eyes (Trigging the error code?)? Link to comment Share on other sites More sharing options...
justsomeguy Posted August 19, 2011 Share Posted August 19, 2011 The first step is to make sure errors are enabled. How long does the script take to finish?ini_set('display_errors', 1);error_reporting(E_ALL); Link to comment Share on other sites More sharing options...
Illasera Posted August 19, 2011 Author Share Posted August 19, 2011 The first step is to make sure errors are enabled. How long does the script take to finish?ini_set('display_errors', 1);error_reporting(E_ALL);After 27 mails ~120 seconds.*FakeDomain = alias for real domain.*FakeIP = Alias for real IPFatal error: Uncaught exception 'Zend_Mail_Protocol_Exception' with message '421 4.0.0 Intrusion prevention active for [FakeIp] ' in /var/www/vhosts/FakeDomain.com/httpdocs/Zend/Mail/Protocol/Abstract.php:378 Stack trace: #0 /var/www/vhosts/FakeDomain.com/httpdocs/Zend/Mail/Protocol/Smtp.php(199): Zend_Mail_Protocol_Abstract->_expect(220, 300) #1 /var/www/vhosts/FakeDomain.com/httpdocs/Zend/Mail/Transport/Smtp.php(196): Zend_Mail_Protocol_Smtp->helo('localhost') #2 /var/www/vhosts/FakeDomain.com/httpdocs/Zend/Mail/Transport/Abstract.php(348): Zend_Mail_Transport_Smtp->_sendMail() #3 /var/www/vhosts/FakeDomain.com/httpdocs/Zend/Mail.php(973): Zend_Mail_Transport_Abstract->send(Object(Zend_Mail)) #4 /var/www/vhosts/FakeDomain.com/httpdocs/sale_of_the_month_august_2011.php(248): Zend_Mail->send(Object(Zend_Mail_Transport_Smtp)) #5 {main} thrown in /var/www/vhosts/FakeDomain.com/httpdocs/Zend/Mail/Protocol/Abstract.php on line 378 Link to comment Share on other sites More sharing options...
justsomeguy Posted August 19, 2011 Share Posted August 19, 2011 It looks like the SMTP server is "protected".http://www.google.com/search?client=opera&...781&bih=966 Link to comment Share on other sites More sharing options...
Illasera Posted August 19, 2011 Author Share Posted August 19, 2011 It looks like the SMTP server is "protected".http://www.google.com/search?client=opera&...781&bih=966 pffff, I am paying for the SMTP server per month to "forget the protection"I contacted them before i posted here but i have yet to recieve an answer, I just came here to verify. Link to comment Share on other sites More sharing options...
Illasera Posted August 19, 2011 Author Share Posted August 19, 2011 pffff, I am paying for the SMTP server per month to "forget the protection"I contacted them before i posted here but i have yet to recieve an answer, I just came here to verify.BTW, Any ways to bypass the problem, I fear my Mailing service provider will tell me "Sorry, Can`t help",My top priority is to bypass without swapping to other mailing APIs. Link to comment Share on other sites More sharing options...
boen_robot Posted August 19, 2011 Share Posted August 19, 2011 But that's just it... no API can bypass this, because it's not an API issue. The best you can do (other than having to turn off the protection at the SMTP server) is a cron job in which you sleep() every few emails to avoid triggering the protection. Alternatively, you could (if the host allows it, or you have your own computer to spare) install your own SMTP server, and send your emails from there. Link to comment Share on other sites More sharing options...
Illasera Posted August 20, 2011 Author Share Posted August 20, 2011 But that's just it... no API can bypass this, because it's not an API issue. The best you can do (other than having to turn off the protection at the SMTP server) is a cron job in which you sleep() every few emails to avoid triggering the protection. Alternatively, you could (if the host allows it, or you have your own computer to spare) install your own SMTP server, and send your emails from there.Well basicly the server am hosting on isn`t a cloud server and they are very strict (Won`t let me change anything), And i dont have a pc that can be used a server, Can`t i dictate the mail sending paradigm to sleep() myself after few mails? Link to comment Share on other sites More sharing options...
boen_robot Posted August 20, 2011 Share Posted August 20, 2011 Can`t i dictate the mail sending paradigm to sleep() myself after few mails?Yes, but the PHP script will easily timeout if it's not in a cron job.But here's another idea... try to add ALL recepients as BCCs. Link to comment Share on other sites More sharing options...
Illasera Posted August 21, 2011 Author Share Posted August 21, 2011 Yes, but the PHP script will easily timeout if it's not in a cron job.But here's another idea... try to add ALL recepients as BCCs.Ok, i want to add BCC as you suggested, How do i write the correct syntax, How is ZEND API parser handles it?, Comma seperated? Link to comment Share on other sites More sharing options...
boen_robot Posted August 21, 2011 Share Posted August 21, 2011 It's all on the linked page... read the notes. Link to comment Share on other sites More sharing options...
Illasera Posted August 21, 2011 Author Share Posted August 21, 2011 It's all on the linked page... read the notes.Nope, I don`t get it or fail to understand, Isn`t easier to write it instead of telling me to re-read it as it clear from my post that i already had? Link to comment Share on other sites More sharing options...
boen_robot Posted August 21, 2011 Share Posted August 21, 2011 It would be easier if I had anything different to say... but all I can say is Zend_Mail::setDefaultTransport(new Zend_Mail_Transport_Smtp('smtp.yoursite.com'));$mail = new Zend_Mail();$mail->addFrom('youremail@yoursite.com')->setSubject('Message subject')->setBodyText('This is the text of the mail.')->addBcc(array('email1@example.com', 'email2@example.org'))->send(); Link to comment Share on other sites More sharing options...
Illasera Posted August 21, 2011 Author Share Posted August 21, 2011 It would be easier if I had anything different to say... but all I can say isZend_Mail::setDefaultTransport(new Zend_Mail_Transport_Smtp('smtp.yoursite.com'));$mail = new Zend_Mail();$mail->addFrom('youremail@yoursite.com')->setSubject('Message subject')->setBodyText('This is the text of the mail.')->addBcc(array('email1@example.com', 'email2@example.org'))->send(); $mail_list=array(); $mail = new Zend_Mail('UTF-8'); while($Row = mysql_fetch_array($Mail_Result)) { $transport = new Zend_Mail_Transport_Smtp('mail.domain.com', $config); $pr_Mail_ID = $Row['IdMail']; $pr_Mail_Address = $Row['MAIL']; $pr_WantNews = $Row['WantMail']; $pr_MailMd5 = md5($pr_Mail_Address); if($pr_WantMail != 1) continue; $mail_list[$Num_Mail_Sent] = $pr_Mail_Address; $Num_Mail_Sent++; $mail_subject = 'test'; $mail_Header = $mail_Body; $mail->addHeader('Content-Language', 'en'); $mail->addHeader('Content-Type', 'multipart/mixed'); $mail->setHeaderEncoding(Zend_Mime::ENCODING_BASE64); $mail->setBodyHtml($mail_Header, 'UTF-8', Zend_Mime::MULTIPART_MIXED); $mail->setFrom('info@domain.com', 'info@domain.com');// $mail->addBcc($pr_Mail_Address, $pr_Mail_Address); $mail->addBcc($mail_list, $mail_list); $mail->setSubject($mail_subject); try { echo "try send mail "; $mail->send($transport); } catch (Zend_Mail_Transport_Exception $e) { echo "$e"; } } and how do i convert it to dynamic array without getting "Notice: Array to string conversion in /var/www/vhosts/Domainl/httpdocs/Zend/Mail.php on line 995And i am guessing it fail to send since am not getting the mail.For some reasons, my code edits doesn`t get edit Link to comment Share on other sites More sharing options...
boen_robot Posted August 21, 2011 Share Posted August 21, 2011 You pass either one array with ALL members, or individual addresses. There could also be some ordering issues around... try to move the mail preparation outside of the array generation, like $mail_list=array(); $Num_Mail_Sent = 0; $mail = new Zend_Mail('UTF-8'); while($Row = mysql_fetch_array($Mail_Result)) { $pr_Mail_ID = $Row['IdMail']; $pr_Mail_Address = $Row['MAIL']; $pr_WantNews = $Row['WantMail']; $pr_MailMd5 = md5($pr_Mail_Address); if($pr_WantMail != 1) continue; $mail_list[$Num_Mail_Sent++] = $pr_Mail_Address; } try { $mail_subject = 'test'; $mail->addHeader('Content-Language', 'en'); $mail->addHeader('Content-Type', 'multipart/mixed'); $mail->setHeaderEncoding(Zend_Mime::ENCODING_BASE64); $mail->setBodyHtml($mail_Body, 'UTF-8', Zend_Mime::MULTIPART_MIXED); $mail->setFrom('info@domain.com', 'info@domain.com'); $mail->addBcc($mail_list); $mail->setSubject($mail_subject); echo "try send mail "; $transport = new Zend_Mail_Transport_Smtp('mail.domain.com', $config); $mail->send($transport); } catch (Zend_Mail_Transport_Exception $e) { echo "$e"; } or alternatively, if you want some human readable names next to the addresses (e.g. their username), then use this (assuming $pr_Mail_ID is that human readable name): $mail_list=array(); $mail = new Zend_Mail('UTF-8'); while($Row = mysql_fetch_array($Mail_Result)) { $pr_Mail_ID = $Row['IdMail']; $pr_Mail_Address = $Row['MAIL']; $pr_WantNews = $Row['WantMail']; $pr_MailMd5 = md5($pr_Mail_Address); if($pr_WantMail != 1) continue; $mail->addBcc($pr_Mail_Address, $pr_Mail_ID); } try { $mail_subject = 'test'; $mail->addHeader('Content-Language', 'en'); $mail->addHeader('Content-Type', 'multipart/mixed'); $mail->setHeaderEncoding(Zend_Mime::ENCODING_BASE64); $mail->setBodyHtml($mail_Body, 'UTF-8', Zend_Mime::MULTIPART_MIXED); $mail->setFrom('info@domain.com', 'info@domain.com'); $mail->setSubject($mail_subject); echo "try send mail "; $transport = new Zend_Mail_Transport_Smtp('mail.domain.com', $config); $mail->send($transport); } catch (Zend_Mail_Transport_Exception $e) { echo "$e"; } Link to comment Share on other sites More sharing options...
Illasera Posted August 21, 2011 Author Share Posted August 21, 2011 well the first example doesn`t work, it seems to be launching the mail send request, But nothing seems to happen, You think maybe its getting blocked by the mailing servers?The second example only send the mail to the first client on the list. Link to comment Share on other sites More sharing options...
boen_robot Posted August 21, 2011 Share Posted August 21, 2011 Yes. Perhaps you're already blacklisted, so whatever you do, it wouldn't work. You need to be capable of either removing the protection or at least somehow clear yourself out of it at least for the test. Link to comment Share on other sites More sharing options...
Illasera Posted August 21, 2011 Author Share Posted August 21, 2011 Yes. Perhaps you're already blacklisted, so whatever you do, it wouldn't work. You need to be capable of either removing the protection or at least somehow clear yourself out of it at least for the test.Am not sure i am blacklist since i can send/receive mails, And i can`t "remove" the protection since am hiring the SMTP service from a shared servers company, i need a VPS/Cloud for it i believe, More $ Link to comment Share on other sites More sharing options...
boen_robot Posted August 21, 2011 Share Posted August 21, 2011 If you can use Zend_Mail() to send individual emails, then there's something else to it. Perhaps if you also add one actual "to" address, like yours for example? Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.