5 Replies - 828 Views - Last Post: 27 May 2015 - 02:40 AM

#1 DocNet  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 118
  • Joined: 11-October 12

Phpmailer send messages in spam folder?

Posted 26 May 2015 - 03:22 AM

Hi everyone,

i'm redesigning an website what i developed few yrs ago.

I finished all frontend and backend stuffs, everything works, just contact page not.

I linked everything like in old website and when i send message to my yahoo account it comes to spam folder with subject
Mail Delivery System, and message:

Quote

This message was created automatically by mail delivery software.

A message that you sent could not be delivered to one or more of its
recipients. This is a permanent error. The following address(es) failed:

SMTP error from remote mail server after end of data:
host mta7.am0.yahoodns.net [63.250.192.46]: 554 5.7.9 Message not accepted for policy reasons. See http://postmaster.ya...tmaster-28.html
... and more private stuffs


when i send mail to mine gmail account, it's not recieved.

So i searched google and find that solutin is to smtp authentication, i don't want to use it, i'm using mail function with this code:

<?php


$status ="Error";
if(isset($_GET['status'])){
if ($_GET['status']=="sent") {
	$status="sent";
        echo '<script type="text/javascript">alert("Poruka je uspešno poslata.")</script>';
}
else if($_GET['status']=="Error"){
echo '<script>alert("Mailer error");</script>';
}
}

// Ako nije popunio polje nema slanja maila, ovde mogu da se provere ostala polja (validacija sa serverske strane)
if (isset($_POST['SenderName']) && isset($_POST['SenderEmail'])
	&& preg_match("/^[a-z0-9&\'\.\-_\+][email protected][a-z0-9\-]+\.([a-z0-9\-]+\.)*+[a-z]{2}/is", $_POST['SenderEmail'])) {


require("phpmailer/class.phpmailer.php");

$SenderName = $_POST['SenderName']; 		// "SenderName" je "name" atribut inputa, isto vazi za ostale inpute
$SenderEmail = $_POST['SenderEmail'];	
$SenderMessage = $_POST['SenderMessage'];

$mail = new PHPMailer();

$mail->IsMail(); // telling the class to use MAIL

$mail->FromName = $SenderName;
$mail->From     = $SenderEmail;
$mail->AddAddress("mymail");

$mail->Subject  = "Poruka sa sajta";
$mail->Body     = $SenderMessage;

//$mail->WordWrap = 50;
//$mail->CharSet="utf-8";
//$mail->IsHTML(true);

try{
$mail->Send();
  echo '<script>location.replace("?status=sent");</script>';
}
catch(Exception $e){
	echo '<script>alert('.$e.')</script>';
}
}
?>



When i press send button it says "Message was sent", but it's message is in spam for yahoo, or nowhere for gmail...

So my question is how to send mail in inbox like before using mail function, without smtp.

my website is in subfolder now like www.oldsite.com/newsite/
Thanks.

Is This A Good Question/Topic? 0
  • +

Replies To: Phpmailer send messages in spam folder?

#2 CTphpnwb  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 3714
  • View blog
  • Posts: 13,469
  • Joined: 08-August 08

Re: Phpmailer send messages in spam folder?

Posted 26 May 2015 - 05:19 AM

You don't. It's being blocked because it hasn't been authenticated. Their servers don't trust that it's legitimate, so they require that it be authenticated.

There's some simple math going on here: Everyone thinks their outgoing mail is important, but most email is spam. IIRC, something like 90%. Either take steps to show that yours isn't in the 90% or have it blocked!

This post has been edited by Dormilich: 27 May 2015 - 11:26 PM

Was This Post Helpful? 0
  • +
  • -

#3 DocNet  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 118
  • Joined: 11-October 12

Re: Phpmailer send messages in spam folder?

Posted 26 May 2015 - 06:41 AM

So i will need to send mail using smtp?
I never used smtp, i just know that it is email protocol.

I really don't know what informations i need to complete phpmailer smtp script and how i open smtp in cpanel?

Script needs to be supplied by for me unknown informations:

$mail->Host = "" <- what here, smtp.site.com or mail.site.com or else?
$mail->Username and Password < - what username and password, of my/client email account or what?


Thanks.

This post has been edited by Dormilich: 27 May 2015 - 11:26 PM

Was This Post Helpful? 0
  • +
  • -

#4 Atli  Icon User is offline

  • Enhance Your Calm
  • member icon

Reputation: 4238
  • View blog
  • Posts: 7,216
  • Joined: 08-June 10

Re: Phpmailer send messages in spam folder?

Posted 26 May 2015 - 07:01 AM

The real problem here isn't the SMTP thing. - The standard sendmail binary used by the mail function on Linux does in fact use SMTP to send mail.

The problem is that you are sending the mail From a random email that most likely doesn't match your email domain. If Google/Yahoo/etc... receive an email from a SMTP server at "example.com", with the email address "[email protected]", then that will trigger a warning in their spam filters. You are effectively sending email from an account that doesn't belong to your server.

So if you want your mail to come through, always make sure the From address matches the domain of the server sending it.

For contact forms, where you want to receive messages from random people and be able to respond to that in your email as if they'd sent it normally through their own email client, I suggest you try using the Reply-To header. - Use a domain email in the From header (like From: [email protected]), and set the address you want to reply to in the Reply-To header (Reply-To: [email protected]).
Was This Post Helpful? 2
  • +
  • -

#5 no2pencil  Icon User is offline

  • Professor Snuggly Pants
  • member icon

Reputation: 6552
  • View blog
  • Posts: 30,682
  • Joined: 10-May 07

Re: Phpmailer send messages in spam folder?

Posted 26 May 2015 - 07:03 AM

** Moved to web servers & hosting **

I would check the reverse dns & ptr records. Most isp's will auto-spam residential ip's, so unless you have commercial grade service, this will be an on-going issue. You will not be able to fix this with code, & it is not an issue caused by code, thus why it was moved.
Was This Post Helpful? 0
  • +
  • -

#6 DocNet  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 118
  • Joined: 11-October 12

Re: Phpmailer send messages in spam folder?

Posted 27 May 2015 - 02:40 AM

View PostAtli, on 26 May 2015 - 07:01 AM, said:

The real problem here isn't the SMTP thing. - The standard sendmail binary used by the mail function on Linux does in fact use SMTP to send mail.

The problem is that you are sending the mail From a random email that most likely doesn't match your email domain. If Google/Yahoo/etc... receive an email from a SMTP server at "example.com", with the email address "[email protected]", then that will trigger a warning in their spam filters. You are effectively sending email from an account that doesn't belong to your server.

So if you want your mail to come through, always make sure the From address matches the domain of the server sending it.

For contact forms, where you want to receive messages from random people and be able to respond to that in your email as if they'd sent it normally through their own email client, I suggest you try using the Reply-To header. - Use a domain email in the From header (like From: [email protected]), and set the address you want to reply to in the Reply-To header (Reply-To: [email protected]).


SOLVED! Thank you.
Soliton is to set sender mail in AddReplyTo function, and in SetFrom add smtp mail, also i used smtp authentication from my hosting smtp mail account.

This post has been edited by DocNet: 27 May 2015 - 02:50 AM

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1