开发者

Problem with sending a batch of email using php

开发者 https://www.devze.com 2023-02-25 11:03 出处:网络
here is my function function send_edm ($u_email_sender_name, $u_content, $u_mail, $u_subject, $edm_id) {

here is my function

function send_edm ($u_email_sender_name, $u_content, $u_mail, $u_subject, $edm_id) {
        foreach ($edm_email as $value) {

            $this->rege = Route :: loadClass('core_route_regclass');
            $this->sendmail = $this->rege->phpmailer();

            $this->sendmail->Mailer = "mail";
            $this->sendmail->IsHTML(true);

            $email_sender = $u_email_sender_name;
            $mail = $config->company_email; 

            $subject = $u_subject;
            $fromwhere = $email_sender; 
            $content = $u_content;      

            $this->sendmail->From = $fromwhere;
            $this->sendmail->FromName = $fromwhere;
            $this->sendmail->AddAddress($value["email"]);

            $this->sendmail->Subject = $u_subject;
            $this->sendmail->CharSet = "utf-8";
        开发者_StackOverflow中文版    $this->sendmail->Encoding = "base64";

            $this->sendmail->Body = $u_content;
            $this->sendmail->AltBody = "This is the body in plain text for non-HTML mail clients";  

            if(!$this->sendmail->Send())
            {
                echo "Message could not be sent. <p>";
            }

        }
}

if i send over 1000 or more email send by using this function, will it be any error occur possibly cause the Interrupt of the sending process? How to increase the reliability of sending email using php?

thanks


For the sending of large amounts of email, it is better to use PEAR::Mail_Queue package.

This package provides classes to handle mail queue management. It can load, save and send saved mails in background and also backup some mails.


THe answer to that question depends on a lot of things that have nothing to do with your code. For instance, does your host throttle the number of emails you can send in a given time period? Have you validated all of your inputs ahead of time? How many mpre than 1000 are we talking about? A 1000 iteration loop is a lot more stable than a 1m iteration loop. Does the server have enough CPU cycle bandwidth to complete the full iteration?

You might want to consider using a worker queue to handle large processing jobs separately from the web site itself.

0

精彩评论

暂无评论...
验证码 换一张
取 消