Yet another mail()/hotmail spam problem

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
mat106
Forum Newbie
Posts: 16
Joined: Wed Aug 31, 2005 2:52 am

Yet another mail()/hotmail spam problem

Post by mat106 »

Hello all.

Can anyone see why email sent with the script below insists on ending up in hotmail's "Junk Email" folder?

Code: Select all

$recipients = array ("user1@hotmail.com", "user2@gmail.com");
					$fromname = "Some name";
					$fromemail = "someemail@domain_unrelated_to_domain_from_which_email_is_sent.com";
					$subject = "Some Subject";

					$message = 'Text';
					$message .= '<br /><br />';
					$message .= 'Text with a link.';
					$message .= '<br /><br />Text';

					foreach ($recipients as $to)
						{
						$headers = "From:$fromname<$fromemail>\r\n";
						$headers .= "To:<$to>\r\n";
						$headers .= "X-Sender:$fromemail\r\n";
						$headers .= "Reply-To:$fromname<$fromemail>\r\n";
						$headers .= "Return-Path:<$fromemail>\r\n";
						$headers .= "MIME-Version: 1.0\r\n";
						$headers .= "Content-type: text/html; charset=iso-8859-1\r\n";
						$headers .= "X-Mailer: PHP/".phpversion()."\r\n";
						$headers .= "X-Priority: 2\r\n";
						$headers .= "X-MSMail-Priority: Normal" . "\r\n";

						$success = mail($to, $subject, $message, $headers, '-fsomeemail@domain_unrelated_to_domain_from_which_email_is_sent.com');
						if ($success)
							{
							echo "Email successfully sent to $to<br />";
							}
							else
							{
							echo "<strong>Email was not successfully sent to $to<br />";
							}
						}
Things i've tried but haven't worked:

1. I've tried changing the X-Priority to 1
2. I've tried removing $headers .= "X-MSMail-Priority: Normal" . "\r\n"; completely.
3. I've tried setting $fromemail, the From: header and the X-sender to either the domain from which the email is sent or a hotmail domain.
4. I've made sure that the actual message is longer than a couple of lines.

user1@gmail.com receives the email fine but user2@hotmail.com always gets it sent to junk folder.

Any ideas?? Thanks.
Charles256
DevNet Resident
Posts: 1375
Joined: Fri Sep 16, 2005 9:06 pm

Post by Charles256 »

probably because of the domain name the e-mail is coming from. your domain might not be recognized as one of their "trusteD" senders and therefore are junk mail:) it's not exactly a script problem:-D
phoenix121
Forum Commoner
Posts: 28
Joined: Sun Sep 25, 2005 9:09 pm
Location: New Zealand

Post by phoenix121 »

yeah, if your emali is filtered to junk, its the content of the email, not your script.

theres an example of that script, but i think its not as good as yours - http://felix.dehnz.net/e/ - click the 'source code' link at the bottom.
User avatar
$var
Forum Contributor
Posts: 317
Joined: Thu Aug 18, 2005 8:30 pm
Location: Toronto

Post by $var »

most host have a filter to accept only recognized/friendly senders.
if your host is smaller, or, perhaps they just haven't gotten around to it,
ask them to look into getting their e-mail verified with the major servers.
RobertPaul
Forum Contributor
Posts: 122
Joined: Sun Sep 18, 2005 8:54 pm
Location: OCNY

Post by RobertPaul »

Code: Select all

$fromemail = "someemail@domain_unrelated_to_domain_from_which_email_is_sent.com";
Eh, that might have something to do with it. Don't quote me on it, though.
Post Reply