Reputation: 875
I have a contact form that submits through php, but I'm having issues getting it to send to my forwarded email address.
I have my site hosted on iPage, and the MX record on iPage points to Hover, where my email and domain is registered/administered. I only have email forwarding set up ([email protected], which forwards to my email I've used for years) on Hover, and it works like a charm. Any emails sent to the [email protected] email get sent straight to my inbox for my email that I've had forever.
However, my php contact form on my site isn't getting the info to my email. If I set the "to" field to send to my email I've used forever, the contact form submits it straight to my email. However, if I use the [email protected] email as the "to" field, the contact form never reaches my inbox.
Here's the php file:
<?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 ("[email protected]", "Quote Request", $email_content, 'From: 456Recordings.com <[email protected]>' );
// send the user back to the form
header("Location: /?s=".urlencode("Thank you for your message.")); exit;
?>
Upvotes: 0
Views: 850
Reputation: 402
This is not an issue with your code, it is an issue with how your domain name and mail server settings were entered. You will need to have your registrar add the ip address of your web server to the spf record for your domain.
Basically when your email provider receives the email they will look up your domain and make sure that the ip address that sent the email is authorized to send email for that domain. If it doesn't recognize the ip address, it just deletes the email.
Odds are the email you have used for ever doesn't use spf filtering (like gmail), and your new email provider does (like godaddy, 1and1, yahoo).
If you google SPF and DKIP you will find more information.
On the slight change your registrar is godaddy, this was saved in my bookmarks http://support.godaddy.com/help/article/7926/adding-or-editing-spf-records
Upvotes: 1