Re: Changed main domain, specified x10 name servers with registrar, site displays err
* UPDATE *
I just realized through email admin in CPanel that the default email account that coes with the free account is not the same as
username@gearvice.com after seeing a return to sender bouceback in the default email account inbox. Doi. So I created
username@gearvice.com and added the headers as indicated in my original reply, but still no email to my personal account as specified by $your_email. However...
I'm making some progress after reading in the forums that external email accounts sometimes don't receive messages via PHP contact forms, at least here at X10. I also set $your_email in my form code to an internal one
username@gearvice.com and now messages are coming through.
Small victory, but a victory nonetheless.
I was hoping I could have the form automatically send an email to my cell phone as a text message... who knows, maybe it still can. But if it can't then I guess I can set up an auto forward rule. Either way, feel free to close this thread unless you have any other relevant thoughts.
* ORIGINAL REPLY *
I didn't specify any From headers in the PHP contact form code when the main domain was previously paperhobbies.com.x10hosting.com and not only did the PHP contact form work, it was lightning fast (received messages in my personal email account only a couple seconds later after submitting them via the form). Here is the code I'm using for the PHP contact form:
Code:
<?php
if(!$_POST) exit;
$email = $_POST['email'];
//$error[] = preg_match('/\b[A-Z0-9._%-]+@[A-Z0-9.-]+\.[A-Z]{2,4}\b/i', $_POST['email']) ? '' : 'INVALID EMAIL ADDRESS';
if(!eregi("^[a-z0-9]+([_\\.-][a-z0-9]+)*" ."@"."([a-z0-9]+([\.-][a-z0-9]+)*)+"."\\.[a-z]{2,}"."$",$email )){
$error.="Invalid email address entered";
$errors=1;
}
if($errors==1) echo $error;
else{
$values = array ('name','email','message');
$required = array('name','email','message');
$your_email = "masked@forprivacy.com";
$email_subject = "New Message: ".$_POST['subject'];
$email_content = "new message:\n";
foreach($values as $key => $value){
if(in_array($value,$required)){
if ($key != 'subject' && $key != 'company') {
if( empty($_POST[$value]) ) { echo 'PLEASE FILL IN REQUIRED FIELDS'; exit; }
}
$email_content .= $value.': '.$_POST[$value]."\n";
}
}
$email_content .= 'company'.': '.$_POST['company']."\n";
$email_content .= 'phone'.': '.$_POST['phone']."\n";
if(@mail($your_email,$email_subject,$email_content)) {
echo 'Message sent! You will receive a reply shortly.';
} else {
echo 'ERROR!';
}
}
?>
I tried adding From headers to match the default email address that comes with the free account anyways and it's still not working. I left the email the form sends the message to as my personal email address I was using before for testing purposes. Updated code:
Code:
<?php
if(!$_POST) exit;
$email = $_POST['email'];
//$error[] = preg_match('/\b[A-Z0-9._%-]+@[A-Z0-9.-]+\.[A-Z]{2,4}\b/i', $_POST['email']) ? '' : 'INVALID EMAIL ADDRESS';
if(!eregi("^[a-z0-9]+([_\\.-][a-z0-9]+)*" ."@"."([a-z0-9]+([\.-][a-z0-9]+)*)+"."\\.[a-z]{2,}"."$",$email )){
$error.="Invalid email address entered";
$errors=1;
}
if($errors==1) echo $error;
else{
$values = array ('name','email','message');
$required = array('name','email','message');
$your_email = "masked@forprivacy.com";
$headers = "From: maskedforprivacy@gearvice.com\r\n";
$email_subject = "New Message: ".$_POST['subject'];
$email_content = "new message:\n";
foreach($values as $key => $value){
if(in_array($value,$required)){
if ($key != 'subject' && $key != 'company') {
if( empty($_POST[$value]) ) { echo 'PLEASE FILL IN REQUIRED FIELDS'; exit; }
}
$email_content .= $value.': '.$_POST[$value]."\n";
}
}
$email_content .= 'company'.': '.$_POST['company']."\n";
$email_content .= 'phone'.': '.$_POST['phone']."\n";
if(@mail($your_email,$email_subject,$email_content,$headers)) {
echo 'Message sent! You will receive a reply shortly.';
} else {
echo 'ERROR!';
}
}
?>
Alas, I am still stumped.