...

View Full Version : php mail problems



nickyfraggle
07-12-2007, 12:34 PM
I've written a send to a friend script. When I tested it to my e-mail account, it always worked. I tried to other account and it's fine.

The person I did it for has had no success...none of the e-mails have been received. How can I improve my script so it is received? Even hotmail seems to block it. It doesn't even end up in the junk box!!

This is my code


$friend_subject = "You might be interested in this";

$filename = "send_to_friend.txt";
$handle = fopen ($filename, "r");
$contents = fread ($handle, filesize ($filename));
$contents = str_replace("Xyour_nameX", $your_name, $contents);
$contents = str_replace("Xyour_emailX", $your_email, $contents);
$contents = str_replace("Xfriend_nameX", $friend_name, $contents);
$contents = str_replace("Xfriend_emailX", $friend_email, $contents);
$contents = str_replace("XmessageX", $message, $contents);
$contents = str_replace("Xfriend_from_emailX", $friend_from_email, $contents);
$contents = str_replace("XpageURLX", $pageURL, $contents);
mail("$friend_email","$friend_subject","$contents","From: $your_name <$friend_from_email>");
fclose ($handle);

The text file simple says

Hello Xfriend_nameX

Xyour_nameX thought you might be interested in this website.

XpageURLX

Any ideas! Thanks guys!

Nicky

_Aerospace_Eng_
07-12-2007, 01:14 PM
Its likely the server you are trying the script on doesn't support the php mail function or much less php.

nickyfraggle
07-12-2007, 01:37 PM
But it does send out. I can receive it fine using my e-mail account...therefore the server must support it?

Or do you mean the mail server of whoever is receiving it? My server does support it.

Thanks,

Nicky

nickyfraggle
07-12-2007, 01:38 PM
The server does support php. The script runs fine AND sends the mail. The problem is simply on the receiving end. Some e-mail accounts are receiving it, others aren't.

I was looking for a way to improve the script so that it is received.

Thanks

_Aerospace_Eng_
07-12-2007, 01:42 PM
Some servers are blacklisted by hotmail and other mail clients due to others on the hosting site who may have abused the system by sending spam. What shows up as the from part when you send the email?

nickyfraggle
07-12-2007, 01:52 PM
It appears as from whoever typed their name into my form. I use Outlook Express - it says its from the person's name but isn't coming up with an e-mail address. Maybe this is why?

The site is hosted with a reputable company (Heart Internet). If it was blacklisted I would also have trouble sending e-mail out from my e-mail address surely? I don't have that problem.

I think it's more to do with the information in the headers maybe? And the fact that it doesn't seem to be coming from any e-mail address....just someone's name.

Thanks,

Nicky

nickyfraggle
07-12-2007, 01:58 PM
Umm...I worked out why it wasn't sending an email address through..

Watch this space...

If this works I owe you a box of chocolates or something...

THANKS!

nickyfraggle
07-12-2007, 03:09 PM
It still isn't sending to all e-mail accounts.

I've tried to add header info


$mail = mail("$friend_email", "$friend_subject", "$contents",
"From: $your_name <$your_email>\n" .
"MIME-Version: 1.0\n " .
"Content-type: text/html; charset=iso-8859-1" .
"X-Mailer: PHP/" . phpversion());

but to no avail.

Someone suggested i try sending it through my smtp server to add the correct headers.

Any ideas?



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum