A community in which webmasters can ask for help with topics such as PHP coding , MySQL , IT jobs, web design, IT security.
Current location:homephp forumphp talk in 2009 yearPrevent sent emails treated as junk mails using php mail function - page 1
User InfoPosts
Prevent sent emails treated as junk mails using php mail function#1
I wrote a PHP script to send emails.

My script is like this:

$headers =  (MIME-Version: 1.0( . "\r\n";
$headers .= (Content-type: text/html; charset=iso-8859-1( . "\r\n";
$headers .= (From: abc@yahoo.com( . "\r\n";

// Email Variables
$toUser = "someone@yahoo.com"; // recipient
$subject = "testing"; // subject
$body = "<html><body><p>
Example of including an image via html \<img\> tag:
<br>
<img src=(../images/profile.jpg(>
<br>
My new picture
<br></p></body></html>"; // content

if (mail($toUser,$subject,$body,$headers)) {
echo "sent";
} else {
echo "failed";
}


Well, of course I use a valid email address for sender and receiver. I did receive the email, but it goes to junk mail. So I went for google research. Is it because of my "header" script problem? If it isn(t, then what could cause my script to send a junk mail? Any solution?

posted date: 2009-04-14 00:57:00


Re: Prevent sent emails treated as junk mails using php mail function#2
I had made out the solution of this problem. click to view my topic...

hope that hepls.

posted date: 2009-04-14 00:57:01


Re: Prevent sent emails treated as junk mails using php mail function#3
Perhaps the problem is that yahoo uses domainkeys verification, which will likely fail for your application given that the mail is not actually coming from yahoo(s servers.

posted date: 2009-04-14 01:06:00


Re: Prevent sent emails treated as junk mails using php mail function#4
Check this: How do you make sure email you send programmatically is not automatically marked as spam?

posted date: 2009-04-14 01:08:00


Re: Prevent sent emails treated as junk mails using php mail function#5
When I(ve once had a similar problem I looked at the headers and found out that my host uses SpamAssassin. So I googled for (SpamAssassin score( and found a multitude of information on how to incorrectly (and thus correctly) form an email.For example: SpamAssassin score list

posted date: 2009-04-14 01:10:00


Re: Prevent sent emails treated as junk mails using php mail function#6
the problem is, the server you(re sending the mail from is not a yahoo server. most spam filters check if they match, otherwise it would (and is - or was) possible to easily fake the sender. ever wondered why you get spam from bill.gates AT microsoft.com or your own mail address?

posted date: 2009-04-14 01:11:00


Re: Prevent sent emails treated as junk mails using php mail function#7
As schnalle said, one problem surely is that the smtp server that you use to send the email and the one thet you specify as From, is different.. the from(s domain whould be the same that the server youre running on.So, you can use the yahoo server to send the email (check if they allow the smtp remote connection, but i guess they do) connecting by smtp, and this will solve 1 problem.Another one is the html contents without the alternative plain text contents, but, this one is less important.I suggest you phpMailer, free and open-source php class to send email, easly to use (i use it event o send mail through gmail server)

posted date: 2009-04-14 01:22:00


Re: Prevent sent emails treated as junk mails using php mail function#8
You(ve got two solutions:use Yahoo(s SMTP using abc@yahoo.com credentials to send mail from abc@yahoo.com;use other from, with your own domain;

posted date: 2009-04-14 01:32:00


Re: Prevent sent emails treated as junk mails using php mail function#9
tested both ways.. failed

posted date: 2009-04-14 02:25:00


Re: Prevent sent emails treated as junk mails using php mail function#10
1. Check mail contentAs others have hinted it is probably marked as spam because your mail looks like spam.I am not sure if you the script that you have posted is the actual one that you are testing.If it has the actual mail body & headers, then running this message through a standard installation of SpamAssassin gives it a spam score of 4.9X-Spam-Status: No, score=4.9 required=5.0 tests=BAYES_50,HTML_IMAGE_ONLY_04, HTML_MESSAGE,MIME_HTML_ONLY,NO_DNS_FOR_FROM,NO_RELAYS autolearn=no version=3.2.5Since the email body has only HTML it has a greater chance of being handled with suspect by most anti-spam solutions.2. Mail server(s IPAnother aspect worth checking will be the IP address of your mail server. Any mail originating from dynamic IP addresses will potentially be considered as SPAM. 3. Blocklists Also check if your IP address is listed in one of the block lists. To start with please check your IP address with http://www.spamhaus.org/lookup.lasso.

posted date: 2009-04-14 07:31:00


Re: Prevent sent emails treated as junk mails using php mail function#11
On your server try to sort your SPF (Sender Policy Framework, Google for SPF record) record out.Make sure you send your e-mails from an existing account on your server/domain.Make sure you have the reply-to address in your header.These are the basic things you can try.

posted date: 2009-06-05 05:27:00


Re: Prevent sent emails treated as junk mails using php mail function#12
if your website domain is mydomain.com then in From headers make sure to use someone@mydomain.com

posted date: 2010-07-22 12:50:00


select page: « 1 2 »
Copyright ©2008-2017 www.momige.com, all rights reserved.