Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/267.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/email/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 已成功发送电子邮件,但未收到电子邮件,且未使用swiftmailer发送垃圾邮件_Php_Email_Swiftmailer - Fatal编程技术网

Php 已成功发送电子邮件,但未收到电子邮件,且未使用swiftmailer发送垃圾邮件

Php 已成功发送电子邮件,但未收到电子邮件,且未使用swiftmailer发送垃圾邮件,php,email,swiftmailer,Php,Email,Swiftmailer,我用的是速递。虽然邮件在本地已成功接收,但在live中无法工作,尽管邮件为“邮件已成功发送”。 代码: require_once APPPATH.'swiftmailer/swift_required.php'; 试一试{ $transport=Swift_MailTransport::newInstance(); //使用创建的传输创建邮件程序 $mailer=Swift\u mailer::newInstance($transport); //创建消息 $message=Swift\u me

我用的是速递。虽然邮件在本地已成功接收,但在live中无法工作,尽管邮件为“邮件已成功发送”。 代码:

require_once APPPATH.'swiftmailer/swift_required.php';
试一试{
$transport=Swift_MailTransport::newInstance();
//使用创建的传输创建邮件程序
$mailer=Swift\u mailer::newInstance($transport);
//创建消息
$message=Swift\u message::newInstance($email\u主题)
->setFrom(数组('xxx@yyy.org“=>”xxx'))
->设置为(数组('abc@gmail.com' => ''))
->setBody($email_message,'text/html');
//发送消息
$result=$mailer->send($message);
$message=array('type'=>'success','message'=>'Email Sent successfully');
}捕获(例外$e){
echo“”;echo$e;die;
$message=array('type'=>'danger','message'=>$e);
}

欢迎提供任何帮助/建议。

成功发送的电子邮件显示了这一点,因为php的功能是将邮件发送到按照php.ini文件中的配置运行的邮件服务器。邮件服务器的任务是发送邮件或不发送邮件。如果邮件服务器配置不正确,则邮件将不会发送,但会显示为成功,因为邮件功能已将邮件发送到服务器,现在邮件服务器的任务是发送邮件或不发送邮件。因此,请检查邮件服务器的日志

require_once APPPATH.'swiftmailer/swift_required.php';

        try {
            $transport = Swift_MailTransport::newInstance();
            // Create the Mailer using your created Transport
            $mailer = Swift_Mailer::newInstance($transport);

            // Create a message
            $message = Swift_Message::newInstance($email_subject)
                ->setFrom(array('xxx@yyy.org' => 'xxx'))
                ->setTo(array('abc@gmail.com' => ''))
                ->setBody($email_message, 'text/html');

            // Send the message
            $result = $mailer->send($message);
            $message = array('type' => 'success', 'message' => 'Email Sent successfully.');

        } catch(Exception $e) {
            echo '<pre>'; echo $e; die;
            $message = array('type' => 'danger', 'message' => $e);
       }