使用PHP代码发送电子邮件

时间:2016-10-18 17:36:01

标签: php email

我正在尝试发送电子邮件。但我的代码不起作用。你能错过哪一步吗?

                                                                                                   发信息                     

Email.php



<?php

if($_REQUEST['name'] == '' || $_REQUEST['email'] == '' || $_REQUEST['message'] == ''):
  return "error";
endif;

if (filter_var($_REQUEST['email'], FILTER_VALIDATE_EMAIL)):

  $to = 'sendmeyour_Query@yahoo.com';

      // prepare header
$header = 'From: '. $_REQUEST['name'] . ' <'. $_REQUEST['email'] .'>'. "\r\n";
$header .= 'Reply-To:  '. $_REQUEST['name'] . ' <'. $_REQUEST['email'] .'>'. "\r\n";

$header .= 'X-Mailer: PHP/' . phpversion();

$subject = "Email from KG Construction Website";

$message .= 'Name: ' . $_REQUEST['name'] . "\n";
$message .= 'Email: ' . $_REQUEST['email'] . "\n";
$message .= 'Message: '. $_REQUEST['message'];

$mail = mail( $to, $url , $message, $header );

return $mail ? "success" : "error";
else:
  return "error";
endif;
?>
&#13;
&#13;
&#13;

请帮我解决这个问题。

0 个答案:

没有答案