【问题标题】:PHPMailer doesn't work on CentOSPHPMailer 在 CentOS 上不起作用
【发布时间】:2013-09-06 17:02:59
【问题描述】:

我有一个使用 PHP 的联系我们页面。像所有联系我们一样,有人点击发送后,它会向我的电子邮件发送警告。

问题是它不起作用。该脚本在我的 localhost 中完美运行,它不仅在服务器上运行,也没有显示任何错误。

        $default_path = get_include_path();
        set_include_path(dirname(__FILE__)."/../");
        require_once("extensions/PHPMailer/class.phpmailer.php");
        set_include_path($default_path);
        $mail = new PHPMailer();
        $mail->IsSMTP(); // send via SMTP
        $mail->SMTPSecure="ssl";
        $mail->Host="smtp.gmail.com";
        $mail->SMTPDebug =0;
        $mail->Port=465;
        $mail->SMTPAuth = true; // turn on SMTP authentication

        $mail->Username = Yii::app()->params['sender_email']; // SMTP username
        $mail->Password = Yii::app()->params['sender_password']; // SMTP password
        $webmaster_email = Yii::app()->params['webmaster_email']; //Reply to this email ID
        $mail->From = $email_address;
        $mail->FromName = "Webmaster";
        $mail->AddAddress($email_address,"");
        $mail->AddReplyTo($webmaster_email,"Webmaster");
        $mail->WordWrap = 70; // set word wrap
        //$mail->AddAttachment("/var/tmp/file.tar.gz"); // attachment
        //$mail->AddAttachment("/tmp/image.jpg", "new.jpg"); // attachment
        $mail->IsHTML(true); // send as HTML
        $mail->Subject = $mailcontent->subject;
        $mail->Body = $mailcontent->body;
        //$mail->AltBody = "This is the body when user views in plain text format"; //Text Body
        $mail->Send();

我认为这是因为服务器配置错误(这是我第一次设置服务器),但我不知道我做错了什么。

防火墙已经设置为允许所有流量,所以不是防火墙问题。

没有错误也没有结果让我很困惑。

【问题讨论】:

    标签: php email yii centos


    【解决方案1】:

    好的,在我检查了所有内容后,结果是由于可疑活动,谷歌阻止了我从服务器访问电子邮件。

    要解除阻止,您需要访问此页面:https://accounts.google.com/DisplayUnlockCaptcha

    然后再次运行脚本。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-02-06
      • 2015-06-20
      • 2015-02-23
      相关资源
      最近更新 更多