Yet another mail() question

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
Monstamash
Forum Newbie
Posts: 5
Joined: Wed Nov 19, 2008 11:15 am

Yet another mail() question

Post by Monstamash »

Sorry to post yet another question, I have hunted this forum but couldn't find an answer.

I have been doing some testing with a very simple mail script.

Code: Select all

<?php
$to = "myemail@hotmail.com";
//$to = "myemail@googlemail.com";
$subject = "My subject";
$txt = "Hello!";
$headers = "From: noreply@pact-oil.co.uk\r\n";
if (mail($to,$subject,$txt,$headers)) {
    echo "Success";
} else {
    echo "Failed";
}
?>
I always get "Success" when I run the script. When I'm using my googlemail email account as the to the email arrives almost instantly. When I change over to my hotmail account as the to the email never arrives, not even in spam. Anyone got any idea why?
User avatar
aceconcepts
DevNet Resident
Posts: 1424
Joined: Mon Feb 06, 2006 11:26 am
Location: London

Re: Yet another mail() question

Post by aceconcepts »

Don't know if you want it sent as plain text or HTML but here you go.

Add the following header:

Code: Select all

 
$headers = "MIME-Version: 1.0\r\n";
$headers .= "Content-type: text/html; charset=iso-8859-1\r\n";
$headers .= "Content-Transfer-Encoding: 7bit\r\n";
 
Monstamash
Forum Newbie
Posts: 5
Joined: Wed Nov 19, 2008 11:15 am

Re: Yet another mail() question

Post by Monstamash »

Hi, Thanks for your reply. I added the extra header info but still the exact same results. Its just a simple plain text email I want to send. Very peculiar behaviour. I'm completely stumped! :banghead:
Post Reply