mail.

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
User avatar
s.dot
Tranquility In Moderation
Posts: 5001
Joined: Sun Feb 06, 2005 7:18 pm
Location: Indiana

mail.

Post by s.dot »

I sent out an update to members of my site.
I got about 1000/1450 back due to these types of errors

Unroutable mail domain "yahoo.com"
Unroutable mail domain "hotmail.com"
Unroutable mail domain "aol.com"

etc...

What does this mean? I doubt it's an error in the code because it sent to the less popular domains.

Here's my code anyways.

Code: Select all

if($action == "gml")
{
	function make_clickable($text) 
	{ 
   	$ret = ' ' . $text; 
  		$ret = preg_replace("#(^|[\n ])([\w]+?://[^ \"\n\r\t<]*)#is", "\\1<a href=\"\\2\" target=\"_blank\">\\2</a>", $ret);  
   	$ret = preg_replace("#(^|[\n ])((www|ftp)\.[^ \"\t\n\r<]*)#is", "\\1<a href=\"http://\\2\" target=\"_blank\">\\2</a>", $ret); 
   	$ret = preg_replace("#(^|[\n ])([a-z0-9&\-_.]+?)@([\w\-]+\.([\w\-\.]+\.)*[\w]+)#i", "\\1<a href=\"mailto:\\2@\\3\">\\2@\\3</a>", $ret); 
   	$ret = substr($ret, 1); 
   	return($ret); 
	}
	$query = mysql_query("SELECT username, email FROM users WHERE activated = 'y'");
	$i = 1;
	while($array = mysql_fetch_assoc($query)){
	$recipient = $array['email'];
	$subject = stripslashes($_POST['subject']);
	$body2 = "Hello, ".$array['username']."<BR><BR>
	".stripslashes(nl2br(make_clickable($_POST['body'])))."<BR><BR>
	<B>Login Info</B><BR>
	--------------------------<BR>
	<B>URL:</B> http://www.showmypro.com<BR>
	<B>Username:</B> ".$array['username']."<BR>
	<B>Password:</B> Not included for security purposes<BR><BR>
	(if you forgot your password, go to http://www.showmypro.com and request a new one.)<BR>
	--------------------------<BR><BR>
	-- You are receiving this email because you are a member of showmypro.com.";
	$additional_headers = "From: scrotaye@showmypro.com\r\n";
	$additional_headers .="Content-type: text/html; charset=iso-8859-1\r\n";
	mail($recipient, $subject, $body2, $additional_headers);
	echo $i++;
   echo "<BR>";
	sleep(1); }
}
?>
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

perhaps this user comment from php.net/mail will help
The most common problem people have with the mail() function is the failure to include an additional header containing the from address in the call (along with the standard from address). This commonly results in failed delivery due to spam filtering at the receiving end. The solution: set your header-from address, or use this function:

Code: Select all

<?
function MAIL_NVLP($fromname, $fromaddress, $toname, $toaddress, $subject, $message)
{
   // Copyright &#65533; 2005 ECRIA LLC, http://www.ECRIA.com
   // Please use or modify for any purpose but leave this notice unchanged.
   $headers  = "MIME-Version: 1.0\n";
   $headers .= "Content-type: text/plain; charset=iso-8859-1\n";
   $headers .= "X-Priority: 3\n";
   $headers .= "X-MSMail-Priority: Normal\n";
   $headers .= "X-Mailer: php\n";
   $headers .= "From: \"".$fromname."\" <".$fromaddress.">\n";
   return mail($toaddress, $subject, $message, $headers);
}
?>
but to be honest I'm not sure if that is the cause of your problem, either way a good place to start
User avatar
s.dot
Tranquility In Moderation
Posts: 5001
Joined: Sun Feb 06, 2005 7:18 pm
Location: Indiana

Post by s.dot »

Thanks.

Initially, it seems to have worked like a charm. =)

I'm only getting returned emails where the user no longer exists, or mailbox is full.
User avatar
s.dot
Tranquility In Moderation
Posts: 5001
Joined: Sun Feb 06, 2005 7:18 pm
Location: Indiana

Post by s.dot »

ah, I thought it would happen.

They just all came back again.. still unrouteable. :(
Post Reply