PHP Mailer taking over 30 seconds to send a welcome email

后端 未结 2 1028
甜味超标
甜味超标 2021-01-21 10:47

So I am using the PHPMailer library in PHP to send a welcome email when ever my users registered, and it takes so long to do this.

It takes around 30 - 50 seconds to act

2条回答
  •  夕颜
    夕颜 (楼主)
    2021-01-21 11:27

    Don't know if PHPMailer is compulsory for you or not, but if it's not I am recommanding SwiftMailer .

    as per my personal Experience It's Really fast and reliable.

    Thanks.

    include_once "inc/swift_required.php";
    
    $subject = 'Hello from Jeet Patel, PHP!'; //this will Subject
    $from = array('jeet@mydomain.com' =>'mydomain.com'); //you can use variable
    
    $text = "This is TEXT PART";
    $html = "This IS HTML";
    
    $transport = Swift_SmtpTransport::newInstance('abc.xyz.com', 465, 'ssl');
    $transport->setUsername('MYUSERNAME@MYDOMAIN.COM');
    $transport->setPassword('*********');
    $swift = Swift_Mailer::newInstance($transport);
    
    
    
        $to = array($row['email']  => $row['cname']);
        $message = new Swift_Message($subject);
        $message->setFrom($from);
        $message->setBody($html, 'text/html');
        $message->setTo($to);
        $message->addPart($text, 'text/plain');
    
        if ($swift->send($message, $failures))
        {
            echo "Send successfulllyy";
        } else {
            print_r($failures);
    
        }
    

提交回复
热议问题