我有一个通过 php 提交的联系表单,但在将其发送到我转发的电子邮件地址时遇到问题。
我的网站托管在 iPage 上,iPage 上的 MX 记录指向 Hover,我的电子邮件和域在此处注册/管理。我只在 Hover 上设置了电子邮件转发(myname@mysite.com,它转发到我使用多年的电子邮件),它就像一个魅力。发送到 myname@mysite.com 电子邮件的任何电子邮件都会直接发送到我的收件箱,以获取我永远拥有的电子邮件。
但是,我网站上的 php 联系表没有将信息发送到我的电子邮件中。如果我将“收件人”字段设置为发送到我一直使用的电子邮件,则联系表单会直接将其提交到我的电子邮件。但是,如果我使用 myname@mysite.com 电子邮件作为“收件人”字段,则联系表永远不会到达我的收件箱。
这是php文件:
<?php
// get the posted data
$name = $_POST["name"];
$band_name = $_POST["band_name"];
$email = $_POST["email"];
$link = $_POST["link"];
$tracking = $_POST["tracking"];
$mixing = $_POST["mixing"];
$mastering = $_POST["mastering"];
$reamping = $_POST["reamping"];
$editing = $_POST["editing"];
$other = $_POST["other"];
$comments = $_POST["comments"];
$songs = $_POST["songs"];
$link_fb = $_POST["link_fb"];
$link_yt = $_POST["link_yt"];
$link_db = $_POST["link_db"];
// check that a name was entered
if (empty($name))
$error = "You must enter your name.";
// check that an email address was entered
elseif (empty($band_name))
$error = "You must enter your band's name.";
elseif (empty($email))
$error = "You must enter your email address.";
// check for a valid email address
elseif (!preg_match("/^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$/", $email))
$error = "You must enter a valid email address.";
elseif (empty($link_fb) && empty($link_yt) && empty($link_db))
$error = "You must enter a link to for either Facebook, Youtube or Dropbox.";
elseif (empty($tracking) && empty($mixing) && empty($mastering) && empty($reamping) && empty($editing) && empty($other))
$error = "You must check either tracking, mixing, mastering, editing or other.";
elseif (empty($comments))
$error = "You must describe your project in detail.";
elseif (empty($songs))
$error = "You must enter a total song number.";
// check if an error was found - if there was, send the user back to the form
if (isset($error)) {
header("Location: /?e=".urlencode($error)); exit;
}
// write the email content
$email_content = "Name: $name\n";
$email_content .= "Email Address: $email\n";
$email_content .= "Band Name: $band_name\n";
if (!empty($link_fb))
$email_content .= "Facebook Link: $link_fb\n";
if (!empty($link_yt))
$email_content .= "YouTube Link: $link_yt\n";
if (!empty($link_db))
$email_content .= "Dropbox Link: $link_db\n";
$email_content .= "Looking for the following services:\n\n";
if (!empty($tracking))
$email_content .= "\tTracking\n";
if (!empty($mixing))
$email_content .= "\tMixing\n";
if (!empty($mastering))
$email_content .= "\tMastering\n";
if (!empty($reamping))
$email_content .= "\tReamping\n";
if (!empty($editing))
$email_content .= "\tEditing\n";
if (!empty($other))
$email_content .= "\tOther\n\n";
$email_content .= "Songs: $songs\n";
$email_content .= "Comments:\n\n\t$comments";
// send the email
mail ("brian@456recordings.com", "Quote Request", $email_content, 'From: 456Recordings.com <webmaster@456recordings.com>' );
// send the user back to the form
header("Location: /?s=".urlencode("Thank you for your message.")); exit;
?>