【发布时间】:2015-08-25 10:27:35
【问题描述】:
我有一个联系表,我正在使用下面的 PHP 脚本从我的联系表中获取电子邮件。我也想将同一电子邮件的副本发送到发件人电子邮件。谁能帮我?。谢谢!
<?php
$errors = '';
$myemail = 'chocolatehills_adventurepark@yahoo.com, chocolatehills88@yahoo.com';//<-----Put Your email address here.
if(empty($_POST['name']) ||
empty($_POST['email']) ||
empty($_POST['subject']) ||
empty($_POST['message']))
{
$errors .= "\n Error: all fields are required";
}
$name = $_POST['name'];
$email_address = $_POST['email'];
$subject = $_POST['subject'];
$message = $_POST['message'];
if (!preg_match(
"/^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$/i",
$email_address))
{
$errors .= "\n Error: Invalid email address";
}
if( empty($errors))
{
$to = $myemail;
$email_subject = "Message from: $name";
$email_body = "New message received. ".
" Here are the details:\n \n NAME: $name \n
SUBJECT: $subject \n
EMAIL ADD: $email_address \n
MESSAGE: $message";
$headers = "From: $email_address\n";
//$headers .= "Reply-To: $email_address";
mail($to,$email_subject,$email_body,$headers);
//redirect to the 'thank you' page
header('Location: contact-us.php');
}
?>
【问题讨论】:
-
您已经发送了一封包含您的代码的电子邮件。是什么阻止您使用相同的结构发送另一个?
-
我想给发件人发同样的邮件
-
知道了。你还没有回答我的问题。
标签: php email copy send sender