Jump to content

Function mail()


Mehdi

Recommended Posts

Hello,

The next script cann't send a message to a mail addresse by "Yahoo" (someone@yahoo.com) but wel to a mail addresse by google (someone@gmail.com).
[code]<html>

<head>
<title>Exercise 14.2</title>
</head>

<body>
<div>
<form method="post" action="<?=$_SERVER['PHP_SELF']?>">
<p>
Insert your mail address: <input type="text" name="mail">
</p>
<p>
Insert the subject: <input name="subject" type="text">
</P>
<p>
<textarea name="message" row="50px" col="70px">
</textarea>
</p>
<p>
<input type="submit" value="Submit">
</p>
</form>
</div>

<?php
$to="someone@yahoo.com";
$from=$_REQUEST['mail'];
$subject=$_REQUEST['subject'];
$message=$_REQUEST['message'];
if (!empty($from) && !empty($subject) && !empty($message)){
mail($to, $subject, $message, "From: $from\r\n") or die("Couldn't send mail");
print "Browser: ".$_SERVER['HTTP_USER_AGENT']."<br>IP address: ".$_SERVER['REMOTE_ADDR'];
}
else {
print "You haven't filled in the form completely!";
}
?>[/code]

Could you help me please?

Thanks,
Link to comment
Share on other sites

if your script sends to [b]anyone at all[/b], the issue is not in your script. the problem is that yahoo has built-in spam block that checks for certain header information and other things that are not in a server-sent email by default. you'll need to do some googling on how to bypass yahoo spam block with PHP sent emails. it may help some just to have your From and Reply-To headers both match:
[code]
<?php
$to  = "me@yahoo.com";
$from = "webmaster@mysite.com";
$sub  = "Testing Yahoo";
$msg  = "Did it go through???";
$head = "From: Webmaster <$from>\r\nReply-To: $from";
mail($to, $sub, $msg, $headers);
?>
[/code]

good luck!
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.