2014-01-29 47 views
2

我在dan.creativeloafing.com创建了一个php应用程序。这只需要表单数据并用它构建一个html页面,然后将该页面的内容发送到[email protected]。几天前,它停止工作。自那以后,我一直在试图弄清楚这一点。我正在使用mail()php函数,并将它切换到PHPMailer库。这应该是发送电子邮件,我得到确认,但没有人收到电子邮件,我没有反弹或任何错误。这是代码的jist:PHPMailer不发送,但没有错误

//PHPMailer 
$mail = new PHPMailer; 

$mail->isSMTP();         // Set mailer to use SMTP 
$mail->Host = 'relay-hosting.secureserver.net';  // Specify main and backup server 
$mail->Port = 25; 
$mail->SMTPAuth = false;       // Enable SMTP authentication 
$mail->SMTPSecure = 'tsl';       // Enable encryption, 'ssl' also accepted 
$mail->Username = '[email protected]';    // SMTP username 
$mail->Password = '*******';       // SMTP password 

$mail->SMTPDebug = 0; 

$mail->WordWrap = 50; 
$mail->From = '[email protected]'; 
$mail->FromName = 'DAN Application'; 
$mail->addAddress('[email protected]');    // Name is optional 
$mail->addReplyTo($repEmail); 
$mail->addCC('[email protected]'); 

$mail->isHTML(true); 

$mail->Subject = "New DAN Request: ".$campaignName; 
$mail->msgHTML(file_get_contents('./tmp/DAN_REQUEST_'.$specialString.$randomNumber.'.html')); 

if(!$mail->send()) { 
     echo '<br />Proposal could not be sent.<br />'; 
     echo 'Mailer Error: ' . $mail->ErrorInfo; 
     exit; 
} else { 
    echo 'Proposal has been sent'; 
} 

脚本总是达到'提案已发送'。太。这真让我抓狂!

+0

发布您的邮箱密码这里是一个坏主意,除非它是一个占位符。 –

回答

0

使用try ... catch和PHPMailer(true); https://github.com/Synchro/PHPMailer/blob/master/examples/exceptions.phps

//Create a new PHPMailer instance 
//Passing true to the constructor enables the use of exceptions for error handling 
$mail = new PHPMailer(true); 

try { 

mail->isSMTP();         // Set mailer to use SMTP 
$mail->Host = 'relay-hosting.secureserver.net';  // Specify main and backup server 
$mail->Port = 25; 
$mail->SMTPAuth = false;       // Enable SMTP authentication 
$mail->SMTPSecure = 'tsl';       // Enable encryption, 'ssl' also accepted 
$mail->Username = '[email protected]';    // SMTP username 
$mail->Password = '*******';       // SMTP password 

$mail->SMTPDebug = 0; 

$mail->WordWrap = 50; 
$mail->From = '[email protected]'; 
$mail->FromName = 'DAN Application'; 
$mail->addAddress('[email protected]');    // Name is optional 
$mail->addReplyTo($repEmail); 
$mail->addCC('[email protected]'); 

$mail->isHTML(true); 

$mail->Subject = "New DAN Request: ".$campaignName; 
$mail->msgHTML(file_get_contents('./tmp/DAN_REQUEST_'.$specialString.$randomNumber.'.html')); 

$mail->send(); 
echo 'Proposal has been sent'; 

} catch (phpmailerException $e) { 
echo $e->errorMessage(); //Pretty error messages from PHPMailer 

} catch (Exception $e) { 
echo $e->getMessage(); //Boring error messages from anything else! 
} 
+0

我试过这个,它仍然回声'已发送提案'。这是否意味着这个问题不是我的目的,而是与主持人(godaddy)? – user3250627

+0

这是可能的,尝试改变与另一台SMTP服务器 –

-1

思考的send()应该被发送()

if(!$mail->Send()) { 
+0

请描述您的解决方案,以及它如何解决手头的问题。这有助于未来的访问者了解您的解决方案。 – War10ck

+0

正确的用法确实是$ mail-> send() – user3250627

1

那么是什么在这里发生的是,GoDaddy的是阻止电子邮件,在其中包含我的域名。我不确定这是否是垃圾邮件问题,但他们目前正在研究它。我收到了使用简单的mail()函数发送的电子邮件,并删除了电子邮件中对omgsurvey.com的任何引用。愚蠢的是,这封邮件只发送到两个电子邮件地址!

1

是不是:

$mail->SMTPSecure = 'tsl'; 

应该是:

$mail->SMTPSecure = 'tls'; 
相关问题