php mail and yahoo.com not vibing

ⅰ亾dé卋堺 提交于 2019-12-08 11:08:36

问题


Ok so Ive recently developed a php contact form for party inquiries.

The form sends one request to the website and one confirmation to the person who fills out the form.

In gmail it seems that both emails are being sent properly. However, if you fill out the form with a yahoo email it will send only the confirmation. Not the request. This is obviously problematic. So I am trying to figure out why.

My php is as follows:

$name = $_POST['name'];
$email = $_POST['email'];
$phone = $_POST['phone'];
$guests = $_POST['guests'];
$type = $_POST['type'];
$month = $_POST['month'];
$day = $_POST['day'];
$year = $_POST['year'];
$message = $_POST['message'];
$formcontent="msg";
$comfirmcontent="msg";
$fromname="mydomain.com";
$fromemail="info@mydomain.com";
$confirmheader=
'From: "' . $fromname . '" <' . $fromemail . '>'  . "\r\n" .
'Reply-To: "' . $fromname . '" <' . $fromemail . '>'  . "\r\n" .
'X-Mailer: PHP v' . phpversion();
$recipient = "info@mydomain.com";
$subject = "Contact From Website";
$mailheader = "From: $email";
mail($recipient, $subject, $formcontent, $mailheader) or die("Error!");
mail($email, $confirmsubject, $comfirmcontent, $confirmheader) or die("Error!");
header('Location: party-form-thank-you.html')

So this email isnt sending from yahoo:

mail($recipient, $subject, $formcontent, $mailheader) or die("Error!"); 

But this one is:

mail($email, $confirmsubject, $comfirmcontent, $confirmheader) or die("Error!");

I thought it may be because the

'X-Mailer: PHP v' . phpversion();

was defined in the confirmation email so I tried writing this into the $mailheader

$mailheader = "From: $email" . "\r\n" .
'X-Mailer: PHP v' . phpversion();

...Didnt work.

So I am asking you all my coding friends for help as to why.

TIA


回答1:


@kaiqing

You were correct, since the variables were defined as the same with different name I think yahoo was having a problem,

I rewrote it as this:

$name = $_POST['name'];
$email = $_POST['email'];
$fromname="BOULETTESLARDER.COM";
$recipient = "info@bouletteslarder.com";
$subject = "Contact From Website";
$mailheader = 'From: "' . $name . '" <' . $email . '>'  . "\r\n" .
'X-Mailer: PHP v' . phpversion();
$confirmheader=
'From: "' . $fromname . '" <' . $recipient . '>'  . "\r\n" .
'Reply-To: "' . $fromname . '" <' . $recipient . '>'  . "\r\n" .
'X-Mailer: PHP v' . phpversion();
mail($recipient, $subject, $formcontent, $mailheader) or die("Error!");
mail($email, $confirmsubject, $comfirmcontent, $confirmheader) or die("Error!");

Now it will submit and send both emails — to the website & to the user — if a user filling out the form has a yahoo address.



来源:https://stackoverflow.com/questions/27933780/php-mail-and-yahoo-com-not-vibing

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!