Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
567 views
in Technique[技术] by (71.8m points)

php - PHPMailer on godaddy server, setup correctly?

I've just signed up for a godaddy server to test a PHP script I'm writing. I'm using PHPMailer to send a emails, it uses the godaddy email Host : relay-hosting.secureserver.net

The problem is that I would like to mark the email as from "me"@gmail.com

When I've sent emails using my gmail address in the AddReplyTo field the recipient email account sends it straight to the Junk folder.

I know there is a fundamental problem here, that I'm sending conflicting headers and this is probably why it gets put into the junk folder.

Can someone please explain to me how I can resolve this. Thank you.

Code:

try {
    $mail = new PHPMailer(true);
    $mail->IsSMTP(); // Using SMTP.
    $mail->CharSet = 'utf-8';
    $mail->SMTPDebug = 2; // Enables SMTP debug information - SHOULD NOT be active on production servers!
    $mail->SMTPAuth = false; // Enables SMTP authentication.
    $mail->Host = "relay-hosting.secureserver.net"; // SMTP server host.

    $mail->AddReplyTo('[email protected]', 'Me');
    $mail->AddAddress('[email protected]', 'Them'); 
    $mail->SetFrom('[email protected]', 'Me');
    $mail->Subject = 'PHPMailer Test Subject via smtp, basic with authentication';
    $mail->AltBody = 'To view the message, please use an HTML compatible email viewer!';
    $mail->MsgHTML("Hi, this is an test email");
    $mail->Send();
} catch (phpmailerException $e) {
    echo $e->errorMessage(); 
} catch (Exception $e) {
    echo $e->getMessage(); 
}
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Alex has it right. You will need to specify a from address that is on your domain, [email protected]. In regards to Pekka's comment about using Google's servers for email that will not work. With Go Daddy shared hosting you must use relay-hosting.secureserver.net to send from.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...