mail() Emails filtered as "junk"

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
anthony88guy
Forum Contributor
Posts: 246
Joined: Thu Jan 20, 2005 8:22 pm

mail() Emails filtered as "junk"

Post by anthony88guy »

So I have a membership area, and I verify each user manually for certain reasons. Each Time I verify a user I would like an email sent to them, saying "Your verified blah blah". With my current code, it sends the email but gets sent to junk mail folder on msn and yahoo. My thunderbird doesn’t accept the email at all.

Code: Select all

$to = "$useremail";
				$subject = "Verification";
				$message = "message";
				$headers  = 'MIME-Version: 1.0' . "\r\n";
				$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
				$headers .= "To: ". $to . "\r\n";		
				$headers .= 'From: Waldo' . "\r\n";
				
				mail($to, $subject, $message, $headers);
User avatar
Pyrite
Forum Regular
Posts: 769
Joined: Tue Sep 23, 2003 11:07 pm
Location: The Republic of Texas
Contact:

Post by Pyrite »

Perhaps an alternative, try PHPMailer class. It is a bit less prone to errors in headers.
User avatar
Skara
Forum Regular
Posts: 703
Joined: Sat Mar 12, 2005 7:13 pm
Location: US

Post by Skara »

add a Reply-To: header identical to the From: header.
From: and Reply-To: should both be email addys, as well.

Code: Select all

$headers .= 'From: waldo@domain.com' . "\r\n";
$headers .= 'Reply-To: waldo@domain.com' . "\r\n";
Everything I've seen that uses mail() will get put in msn's and yahoo's junk folders, though. ;)
traherom
Forum Newbie
Posts: 13
Joined: Tue Mar 15, 2005 6:43 am

Doesn't make sense...

Post by traherom »

Using mail() isn't the reason your email's are getting labeled as junk. The receiver has no idea how the email was sent.

My guess is that the use of the work "verification" in the subject is the cause of your trouble. Try it with something different. (Or just for a test, something completely nuetral, like "birthday." :) )
anthony88guy
Forum Contributor
Posts: 246
Joined: Thu Jan 20, 2005 8:22 pm

Post by anthony88guy »

Tried both your suggestions no luck. Hows does PhpBB send their mail?
AGISB
Forum Contributor
Posts: 422
Joined: Fri Jul 09, 2004 1:23 am

Post by AGISB »

Here is the reason the mail is labled as junk:

mail() uses sendmail to send the mail. Sendmail rewrites the header and adds itself to it. This leads to the problem that the sender cannot be verified by the receiver.
This can only be fixed by adding the last parameter to mail() which leads to a header warning or using another mail function that has its own mail client.

phpmailer works perfectly for this.
Post Reply