When i try to send a mail with PHPmailer via gmail smtp server the mail will be flagged as spam. i am using a hotmail account to receive the email.
i've looked to other topics about this problem but they mention that they set the "from" to their own domain name but for me [email protected] is good enough.
this is the code i use:
$mail = new PHPMailer();
$body = "test";
$mail->IsSMTP();
$mail->SMTPDebug = 1;
$mail->SMTPAuth = true;
$mail->SMTPSecure = "ssl";
$mail->Host = "smtp.gmail.com";
$mail->Port = 465;
$mail->Username = "[email protected]";
$mail->Password = "mypassword";
$mail->SetFrom('[email protected]', 'myaccount');
$mail->Subject = "Test subject";
$mail->MsgHTML($body);
$address = "[email protected]";
$mail->AddAddress($address, "test");
$mail->Send()
I've read this topic: How do you make sure email you send programmatically is not automatically marked as spam?
but like i said i don't need my own domain name. Or is this impossible and do i need to use my own domain and use SPF and DKIM?
Edit:
I've tested sending emails to yahoo and gmail and both work only hotmail will mark them as spam.
Solved:
I tried to send a mail with the gmail webclient and even then my mail gets flagged as spam. Somehow the gmail smtp servers are blacklisted. So i created an hotmail account and changed the code to use hotmail smpt server.
$mail->SMTPSecure = "tls";
$mail->Host = 'smtp.live.com';
$mail->Port = 587;
Now my mails are not marked as spam anymore on yahoo gmail and hotmail.