显示电子邮件成功但未收到电子邮件godaddy

时间:2017-07-22 18:51:43

标签: php phpmailer

你好phpmailer在我在localhost上使用时工作但是由于某种原因,当我使用GoDaddy的托管时,它将不再起作用。

我已经关注了与此相关的几乎所有内容,但似乎我找不到任何解决方案:

 require 'PHPMailerAutoload.php';
$mail = new PHPMailer;
$message = "Test";
$mail->isSMTP(); 
$mail->Host = 'relay-hosting.secureserver.net';
$mail->SMTPAuth = true;
$mail->Username = 'mycpanelusername'; 
$mail->Password = 'mycpanelpassword';
$mail->SMTPSecure = 'ssl';
$mail->Port = 25; 
$mail->setFrom('testemail@gmail.com', 'Mailer');
$mail->addAddress($email, 'Joe User');
$mail->addAddress('ellen@example.com');
$mail->addReplyTo('info@example.com', 'Information');
$mail->addCC('cc@example.com');
$mail->addBCC('bcc@example.com');
$mail->addAttachment('/var/tmp/file.tar.gz');  
$mail->addAttachment('/tmp/image.jpg', 'new.jpg');
$mail->isHTML(true);  
$mail->Subject = 'Here is the subject';
$mail->Body    = $message ;
$mail->AltBody = 'This is the body in plain text for non-HTML mail clients';
if(!$mail->send()) {
    echo 'Message could not be sent.';
    echo 'Mailer Error: ' . $mail->ErrorInfo;
} else {
    echo 'Message has been sent';
}

1 个答案:

答案 0 :(得分:1)

你必须使用它来实际发送电子邮件,最后:

$mail->send();

并获得更多信息:

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