5

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('me@gmail.com', 'Me');
    $mail->AddAddress('them@hotmail.co.uk', 'Them'); 
    $mail->SetFrom('me@gmail.com', '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(); 
}
Machavity
  • 28,730
  • 25
  • 78
  • 91
blacktea
  • 142
  • 1
  • 2
  • 12
  • Set a proper `from` address that is actually handled by the server you're sending from. That might already be enough. – Pekka Jun 11 '12 at 16:55
  • 3
    You're sending from a godaddy server but claiming to be a gmail account. You're spoofing, essentially. (I.e., the recipient server says, "Hey this email claims to be from gmail but didn't come from a gmail server, so it's probably fake.") – Alex Howansky Jun 11 '12 at 16:57
  • Do you mean use an godaddy email address? Unfortunately I need to use my gmail address in the from field. Thanks for your quick response – blacktea Jun 11 '12 at 16:57
  • Then you need to send the E-Mail through Google's servers. There's no other way to do this. – Pekka Jun 11 '12 at 18:56

2 Answers2

8

Alex has it right. You will need to specify a from address that is on your domain, me@myhostedexampledomain.com. 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.

Mike_GoDaddy
  • 1,118
  • 1
  • 6
  • 9
3

I used this example with one change:

$mail->Host = "localhost"; // SMTP server host.

GoDaddy requires using "localhost" when using PHPMailer.