email sends to spam of gmail account - php

I have set automatically to send email to users from my website. but this email will place to spam of users with gmail accounts.However it is working fine with yahoo or hotmail accounts.
How should I solve this?
$to = "$Email";
$subject = "Greeting";
$message = 'message here';
$from = "sender#example.com";
$headers = "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-type:text/html;charset=iso-8859-1" . "\r\n";
$headers .= "From: sender#example.com" . "\r\n" .
"Reply-To: sender#example.com" . "\r\n";
mail($to,$subject,$message,$headers);

Since your headers appear to be correct, it's probably keying on something within the message. One of the things that SpamAssassin (no idea if this is what Gmail uses) keys on is a very short message like the above containing a hyperlink or graphic, so you may benefit by actually making your message a little longer. One of the ways to find out is to send it to your own gmail account and when it appears in your spam folder, examine the headers there for any added spam information. It may contain clues as to what spam engine Gmail is using or what rules your message is breaking.
Please have a look here:
Spam sent to Contacts -
Message Delivery
Hope this helps!

it should be of smtp configuration email and site information email id should be diffrent.

Related

how do i add From in your php email [duplicate]

I'm building a website that sends and email to a user when he registers.
My code (the gist of it):
<?php
$to = "helloworld#gmail.com";
$subject = "Test mail";
$message = "Hello! \nThis is a simple email message.";
$headers = "From: munged#gmail.com";
$headers .= "\r\nReply-To: munged#gmail.com";
$headers .= "\r\nX-Mailer: PHP/".phpversion();
mail($to,$subject,$message,$headers);
echo "Mail Sent.";
?>
the problem is that when the mail is delivered, the from header remains munged#box123.bluehost.com, while reply-to gets changed to the specified value.
box123.bluehost.com is the hostname of the server on which the website is hosted.
So what am I doing wrong? What can I do to get the "From" address the same as the reply-to address?
Is it something I'm doing wrong, or is the web host playing foul?
Edit: I just noted that you are trying to use a gmail address as the from value. This is not going to work, and the ISP is right in overwriting it. If you want to redirect the replies to your outgoing messages, use reply-to.
A workaround for valid addresses that works with many ISPs:
try adding a fifth parameter to your mail() command:
mail($to,$subject,$message,$headers,"-f your#email.here");
It turns out the original poster's server (blueHost) has a FAQ concerning this very question.
Article 206.
This is because our servers require you (or your script) to use a properly formatted, valid From: field in the email's header. If the From: field is not formatted correctly, empty or the email address does not exist in the cPanel, the From: address will be changed to username#box###.bluehost.com.
You must change the script you are using to correctly use a valid From: header.
Examples of headers that should work would be:
From: user#domain.com
From: "user" <user#domain.com>
Examples of headers that will NOT work:
From: "user#domain.com"
From: user # domain.com
From: user#domain.com <user#domain.com>
Our servers will not accept the name for the email address and the email address to be the same. It will not accept a double declaration of the email address.
For scripts such as Joomla and Wordpress, you will need to follow their documentation for formatting the from fields properly. Wordpress will require the Mail From plugin.
Note: The email address you use must be a valid created account in the
cPanel.
I had the same Issue, I checked the php.net site. And found the right format.
This is my updated code.
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$headers .= 'From: ' . $fromName . ' <' . $fromEmail .'>' . " \r\n" .
'Reply-To: '. $fromEmail . "\r\n" .
'X-Mailer: PHP/' . phpversion();
The \r\n should be in double quotes(") itself, the single quotes(') will not work.
In order to prevent phishing, some mail servers prevent the From from being rewritten.
I realize this is an old thread, but i had the same problem since i moved to bluehost yesterday. It may not have been the selected answer but i support the bluehost article 206 reply.
I created a valid email in control panel and used it as my From address and it worked.
I solved this by adding email accounts in Cpanel and also adding that same email to the header from field like this
$header = 'From: XXXXXXXX <test#test.org>' . "\r\n";
The web host is not really playing foul. It's not strictly according to the rules - but compared with some some of the amazing inventions intended to prevent spam, its not a particularly bad one.
If you really do want to send mail from '#gmail.com' why not just use the gmail SMTP service? If you can't reconfigure the server where PHP is running, then there are lots of email wrapper tools out there which allow you to specify a custom SMTP relay phpmailer springs to mind.
C.
headers were not working for me on my shared hosting, reason was i was using my hotmail email address in header.
i created a email on my cpanel and i set that same email in the header yeah it worked like a charm!
$header = 'From: ShopFive <site#mysite.org>' . "\r\n";

How to prevent HTML email not ending up in junk folder in hotmail?

I have been sending an email to the user who signs up on my website. The email is correctly being sent to inbox folder in other services like gmail, yahoo but in case of hotmail sometimes it ends up in junk folder and sometimes it goes to inbox.
Below is my email code snippet from my registration code:
$user->save();
$activationUrl = Yii::app()->request->getBaseUrl(true) . '/site/activateaccount?activation_key=' . $activationKey;
$body = $this->renderPartial('accounts/registration_email', array('activationUrl' => $activationUrl), true);
$subject = 'Please complete your signup';
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'From: Website Name<admin#mydomain.com>' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$headers.='Reply-To: admin#mydomain.com' . "\r\n";
$headers.='Return-Path: admin#mydomain.com\r\n';
if (mail($user->email, $subject, $body, $headers)) {
$this->redirect('registersuccess');
}
Please note that the email I send is HTML email and in above code I have replaced website domain with mydomain.com for privacy and website actual name with Website Name.
I have tried changing email subject line, MIME-version and content type.
Tried so many solutions already posted on SO here but no one makes it always go to inbox rather than junk.
My clinet has email account on hotmail so he wants that email to end up in inbox no matter what. Can something be done as sure shot solution? Does installing SSL on site domain solves this issue? Any other solution?

PHP mail() and hotmail

I'm launching a product today and COMPLETELY OUT OF NOWHERE hotmail accounts can't receive email from my php mail() script.
I've searched around and found others with similar problems but haven't found a true solution
$Email = "my#email.com";
$Name = "My name";
$headers = "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-type:text/html;charset=iso-8859-1" . "\r\n";
$headers .= "From: ". $Name . " <" . $Email . ">\r\n";
$body = "bleh";
mail($recipient, "My email", $body, $headers);
It sends fine to GMail etc just not hotmail.
Anyone conquered a similar problem? It doesn't go into SPAM either
Try to use SMTP instead. Mails from mail() often go to spam folder, because servers can't verify source of message.
Is this the exact code you're using?
A long shot, but could there be a conflict in your e-mail validation (if there is one)? A while ago I had an issue where regex wasn't catching hotmail accounts, took me so long to figure it out.
Else, I agree with other responders that some mail services simply delete what they think is spam, I think there's a "spam level" thing where you set how aggressive the spambot is.
Hope this helps.

php mail function not sending email to gmail account only

i am facing a weird problem in my php script. i have made a function to send email and calling the function in my php page. the function works fine when i send mail to yahoo or any other domain but fails when it comes to send mail to the gmail account.below is my code
function send_mail($p_to , $p_sub, $p_body)
{
$from = 'xxx#mydomain.com';
$to = $p_to;
$email_subject = $p_sub;
$email_body = $p_body;
$xheaders = "";
$xheaders .= "From: <$from>\n";
$xheaders .= "X-Sender: <$from>\n";
$xheaders .= "X-Mailer: PHP\n"; // mailer
$xheaders .= "X-Priority: 1\n"; //1 Urgent Message, 3 Normal
$xheaders .= "Content-Type:text/html; charset=\"iso-8859-1\"\n";
mail($to,$email_subject,$email_body,$xheaders);
}
//
when i send mail directly to a gmail account for example if a create a new page with the above code by taking hardcoded values for all the fields($p_to,$p_subject,$p_body) and sends mail then it works .
it was working fine earlier and sending mails to gmail account but, somehow stopped working for gmail.i checked the spam bucket also but found nothing.
any idea frnds ???
Google marks all not verified domains as blacklisted, so your email will be directly moved to the spam box of the gmail user. I think the only thing you can do is to send a mail to the customer service of google and ask if they can verify your domain as safe, but only if you find it really important that gmail users get it in their inbox and not in their spam box.
problem was sorted out. server side modification needed.
Thanks for your replies guys :)

php mail() doesnt work for gmail and hotmail

I am trying to send new system generated password using mail() in php. The thing is I am able to send it to yahoo but when I use gmail or hotmail I dont receive any emails although the function returns true. Following is the function:
if(mail($to,$subject,$body))
{
return true;
}
else
{
return false;
}
It probably ends up in the spam folder look there. If its there make sure your email headers are perfect.
You could look into librairies for what you want to achieve. Zend_Mail has everything you could need to connect to gmail and others.
If you are getting the mail successfully through yahoo, you should also post the headers that are coming through from yahoo here in the question. My bet is you will need to include a "from field" also to get through on hotmail, gmail, etc...
Your problem might be the antispam filters. E-mails sent from PHP are usually marked as spam by the mail servers and end up deleted or in the spam can.
You can Google for "php mail spam" to get some hints of how to work around this issue.
Maybe you're on a shared server and the IP is banned/blocked due to spamming by other users (websites) of your server.
Try adding SPF records.
Ensure that your envelope-FROM (a.k.a. return path) is set to a valid email address that you have access to. If you're not seeing the message in the spam folders, it should be getting bounced; the bounce message may offer a clue as to why the mail is not getting through.
I would try to include your own headers in your mail function
$headers = "MIME-Version: 1.0\r\n";
$headers .= "Content-type: text/html; charset=iso-8859-1\r\n";
$headers .= "Date: ". date('r'). " \r\n";
$headers .= "Return-Path:youremail#domain.com\r\n";
$headers .= "Errors-To:youremail#domain.com\r\n";
$headers .= "From:youremail#domain.com <youremail#domain.com>\r\n";
$headers .= "Reply-to:youremail#domain.com \r\n";
$headers .= "Organization: YourOrg \r\n";
$headers .= "X-Sender:youremail#domain.com \r\n";
$headers .= "X-Priority: 3 \r\n";
$headers .= "X-MSMail-Priority: Normal \r\n";
$headers .= "X-Mailer: PHP/" . phpversion();
mail($to,$subject,$body,$headers);
Try checking if your mailserver ip is blacklisted anywhere?
http://www.mxtoolbox.com/blacklists.aspx
If not, try harder with the headers that are being sent with the mail.

Categories