Page 1 of 1

mail() funtion is not sending mails to yahoo,gmail,hotmail

Posted: Fri Mar 12, 2010 6:48 am
by iamroming
Hello Dear Coders
Help is needed to over come the issue of mail() function, it is not sending the mail to yahoo, gmail and hotmail i have tried even setting the init_set() function but it is still not sending the mail. Please help me in this

Re: mail() funtion is not sending mails to yahoo,gmail,hotmail

Posted: Fri Mar 12, 2010 6:59 am
by heronfisher
There is a possibility you did not set proper header data, and those emails are blocked even before reaching folder.
Try adding something like this:
$headers = 'From: your@email.com' . "\r\n" .
'Reply-To: some@email.com';
This is the fourth parameter of mail() function.

Re: mail() funtion is not sending mails to yahoo,gmail,hotmail

Posted: Fri Mar 12, 2010 7:20 am
by iamroming
Sir thanks for your response i have added the header and it is still not sending the mail

mail() function is not sending mail to yahoo even after head

Posted: Fri Mar 12, 2010 4:11 pm
by iamroming
any body help me to over come this i have added the headers but it is sending the mail to other than yahoo,gmail and hotmail please hel me iam writing down the code here

Code: Select all

<?
 
/***********************
CLASS :: MYMail
************************/
class MyMail{
var $To;
var $ToSender;//If you want the email to go to the sender
var $Subject;
var $Msg;
var $Headers;
var $From;
var $ReplyTo;
/* 
$headers = 'From: webmaster@example.com' . "\r\n" .
'Reply-To: webmaster@example.com' . "\r\n" .
'X-Mailer: PHP/' . phpversion();
mail($to, $subject, $message, $headers);
***&&&&&*******
For HTML Mail
'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
*/
function MyMail($To, $Subject, $Msg, $From, $ReplyTo){
$this->To=(empty($To)) ? "0" : $To;
$this->Subject=(empty($Subject)) ? "0" : $Subject;
$this->Msg=(empty($Msg)) ? "0" : $Msg;
$this->From=(empty($From)) ? "0" : $From;
$this->ReplyTo=(empty($ReplyTo)) ? "0" : $ReplyTo;
$this->Headers="MIME-Version: 1.0" . "\r\n" . "Content-type: text/html; charset=iso-8859-1" . "\r\n" . "From:" . $this->From . "\r\n" . "Reply-To:" . $this->ReplyTo . "\r\n" . "X-Mailer: PHP/" . phpversion();
 
//Use this array if you want to send to only one person
$SetMail=array(
'To'=> $this->To,
'Subject'=> $this->Subject,
'Msg'=> $this->Msg,
'Headers'=> $this->Headers,
'From'=> $this->From,
'ReplyTo'=> $this->ReplyTo
);
//Use this array if you want it to go to multiple people (the sender/CC:/Bcc:)
/*
$SetMail=array(
'To'=> $this->To . "," . $ToSender,
'Subject'=> $this->Subject,
'Msg'=> $this->Msg,
'Headers'=> $this->Headers,
'From'=> $this->From,
'ReplyTo'=> $this->ReplyTo
);
*/
if(in_array("0",$SetMail)){
echo "<div align=\"left\"><font color=\"#640000\">Something wrong with the mail! Please make sure all fields are filled in!</font></div>";
return;
}
else{
if(!mail($SetMail['To'], $SetMail['Subject'], $SetMail['Msg'], $SetMail['Headers'])){
echo "<script type=\"text/javascript\">window.location… is a problem with the Mail!\"</script>";
}
} 
}
}
?>
 
<?
 
 
$MyMail=new MyMail($To="admin@mywebsite.com", $Subject="$subject", $Msg="$message", $From="admin@mywebsite.com", $ReplyTo="admin@mywebsite.com");
 
header("Location:mailsent.php");
?>

Re: mail() funtion is not sending mails to yahoo,gmail,hotmail

Posted: Fri Mar 12, 2010 7:47 pm
by scarface222
check your junk mail. mail with no attachments often gets filtered as junk.