梨(SMTP)Mail.php不会发送,没有错误

时间:2017-08-25 22:51:31

标签: php email

我正在尝试使用PEAR的Mail.php通过cPanel邮件服务器(在托管服务器上运行)发送带有SMTP的电子邮件

该脚本与邮件服务器位于同一服务器上。

我没有收到任何错误,但我也没有收到任何邮件,我不知道为什么:/

我的代码:

Email.php

<?php
ini_set("include_path", '/home/gamerfin/php:'); 

require_once "Mail.php";

class Email{

function mailClient(){
    return Mail::factory('smtp', array(
        'host' => 'ssl://mail.gamerfinder.net',
        'port' => '465',
        'auth' => true,
        'debug' => true,
        'username' => 'messenger@gamerfinder.net', //your gmail account
        'password' => '*********' // your password
    ));

}

function send(){}

function newMessageMail($sender, $email, $message){
    echo $email;
    $smtp = self::mailClient();
    $from = 'messenger@gamerfinder.net'; //change this to your email address
    $to = $email; // change to address
    $subject = 'New Message from '.$sender; // subject of mail
    $body = "You have recieved a new message from ".$sender."<br>Message:<br>".$message; //content of mail

    $headers = array(
        'From' => $from,
        'To' => $email,
        'Subject' => $subject
    );
    $mail = $smtp->send($to, $headers, $body);

    var_dump ($mail);
}
}

?>

谁能看到我可能出错的地方?

我已经查看了其他问题并尝试了一些答案,但没有运气:/

由于

修改

这是邮件调试日志:

DEBUG: Recv: 220-cloud536.unlimitedwebhosting.co.uk ESMTP Exim 4.89 #1 Fri, 25 Aug 2017 23:52:55 +0100 
DEBUG: Recv: 220-We do not authorize the use of this system to transport unsolicited, 
DEBUG: Recv: 220 and/or bulk e-mail.
DEBUG: Send: EHLO localhost

DEBUG: Recv: 250-cloud536.unlimitedwebhosting.co.uk Hello localhost [149.255.60.167]
DEBUG: Recv: 250-SIZE 52428800
DEBUG: Recv: 250-8BITMIME
DEBUG: Recv: 250-PIPELINING
DEBUG: Recv: 250-AUTH PLAIN LOGIN
DEBUG: Recv: 250 HELP
DEBUG: Send: AUTH LOGIN

DEBUG: Recv: 334 VXNlcm5hbWU6
DEBUG: Send: bWVzc2VuZ2VyQGdhbWVyZmluZGVyLm5ldA==

DEBUG: Recv: 334 UGFzc3dvcmQ6
DEBUG: Send: ***************

DEBUG: Recv: 235 Authentication succeeded
DEBUG: Send: MAIL FROM:
<messenger@gamerfinder.net>
  DEBUG: Recv: 250 OK
    DEBUG: Send: RCPT TO:
  <jamiemac262@gmail.com>
    DEBUG: Recv: 250 Accepted
    DEBUG: Send: DATA

DEBUG: Recv: 354 Enter message, ending with "." on a line by itself
DEBUG: Send: From: messenger@gamerfinder.net
To: ***********@gmail.com
Subject: New Message from jamiemac262


DEBUG: Send: You have recieved a new message from jamiemac262<br>
Message:<br>
jamiemac262 has accepted your request to play Elite Dangerous
DEBUG: Send: 
.

DEBUG: Recv: 250 OK id=1dlNTD-0006DI-TS
DEBUG: Send: QUIT

DEBUG: Recv: 221 cloud536.unlimitedwebhosting.co.uk closing connection

1 个答案:

答案 0 :(得分:0)

我设法解决了这个问题。

问题在于我的垃圾邮件得分为2.0,我的主机阻止任何垃圾邮件得分为2或更高的邮件。

我的主人非常友好地向我发送邮件网关日志,告诉我导致垃圾邮件分数的原因。

我可以通过在from标题中添加名称并添加date标题

来解决此问题
'From' => '"Gamer Finder" <messenger@gamerfinder.net>',
        'To' => 'email@gmail.com',
        'Subject' => $subject,
        'Date'  => date("r")

所以对于有类似问题的人,做一些研究,找出可以触发垃圾邮件规则的内容,并确保你不会触发它们。