Jump to content

The mail() function doesn't like dots


marmite

Recommended Posts

As soon as i include dots in the address below, the mail function falls over.

 

So I've escaped them with "/" but now the email actually prints out "www/.cardsunlimited/.com" !

 

Does anyone know how to get round this problem? Thanks! :)

 

	$message .= "www/.cardsunlimited/.com \n";
	$email=$row[email_address];
	mail($email, "Cards Unlimited: Forgotten Password", $message, $headers);

Link to comment
https://forums.phpfreaks.com/topic/49630-the-mail-function-doesnt-like-dots/
Share on other sites

Sorry. I think all I need is to escape the dots, but / and \ don't work.

 

1) If $message contains "www.cardsunlimited.com", the mail does not send. Where would I find errors? (I'm new to this. I only have access to part of the server. I have some .gz files in a log folder... but they appear to be in Chinese)

 

2) If $message contains "www/.cardsunlimited/.com" instead, it sends the email with "www/.cardsunlimited/.com"

 

3) If $message contains "www\.cardsunlimited\.com" instead, I changed this to backslashes and it sends the email as "www\.cardsunlimited\.com"

 

This code works:

 

if ($_POST['fpwd_x']) {
// Check username and password
$fu = $_POST['username'];
$query = sprintf("SELECT * from users where username = '%s'", mysql_real_escape_string($fu));
$result = mysql_query($query) or die("Error in query " . mysql_error());
$numrows = mysql_num_rows($result);
if ($numrows > 0) {
	$row = mysql_fetch_assoc($result);
	$headers = "From: Cards Unlimited Password Recovery <[email protected]>\n\r";
	$message = "Dear $row[first_name], \n\n";
	$message .= "Your password for Cards Unlimited is: $row[password] \n\n";
	$message .= "Thank you for your custom, \n";
	$message .= "The Cards Unlimited team \n";
	$email=$row[email_address];
	mail($email, "Cards Unlimited: Forgotten Password", $message, $headers);
} else {
	$error = "Sorry, username does not exist";
}
}

 

This code doesn't (one line added: final $message line)

if ($_POST['fpwd_x']) {
// Check username and password
$fu = $_POST['username'];
$query = sprintf("SELECT * from users where username = '%s'", mysql_real_escape_string($fu));
$result = mysql_query($query) or die("Error in query " . mysql_error());
$numrows = mysql_num_rows($result);
if ($numrows > 0) {
	$row = mysql_fetch_assoc($result);
	$headers = "From: Cards Unlimited Password Recovery <[email protected]>\n\r";
	$message = "Dear $row[first_name], \n\n";
	$message .= "Your password for Cards Unlimited is: $row[password] \n\n";
	$message .= "Thank you for your custom, \n";
	$message .= "The Cards Unlimited team \n";
	$message .="www.cardsunlimited.com \n";
                $email=$row[email_address];
	mail($email, "Cards Unlimited: Forgotten Password", $message, $headers);
} else {
	$error = "Sorry, username does not exist";
}
}

Good God!

 

You're right, the messages are all in spam! That fixes a bunch of problems...

 

Thank you!

 

Is there any way to keep the link in there, but escape the spam filters?

 

Thanks, you've saved me loads of time (and a stress-induced ulcer, I suspect).

Emma

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.