help with email script...


Posted on 16th Feb 2014 07:03 pm by admin

hey

I need help with my mail script

when the form on http://www.mcgdesignstudio.com/contact.html is filled out, it send the from with no errors.. however i never receive it..

my hosting company have told me as long as i have the fourth element in if -f or something it will work, dunno where to put that though..

this is my script:

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 = "martin@mcgdesignstudio.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 'You need to fill in all the required fields...'; exit; }
}
$email_content .= $value.': '.$_POST[$value]."n";
}
}

if(mail("$your_email", "$email_subject", "$email_content",
"To: Martin Greenwood <$your_email >n" .
"From: mcgdesignstudio.com <martin@mcgdesignstudio.com>n" .
"MIME-Version: 1.0n" .
"Content-type: text/html; charset=iso-8859-1"
)){
echo 'Your message has been sent successfully..';

} else {

echo 'Oops, something went wrong...try again later.';

}

}

?>

No comments posted yet

Your Answer:

Login to answer
136 Like 52 Dislike
Previous forums Next forums
Other forums

Operator precedence assistance.
I did a quick Google search and couldn't quite find the answer I wanted in terms I could understand,

using explode() to fill in checkboxes
Hi

I have a field stored in a table that contains regions in the UK separated by commas. Ther

session variable problem
Session variable is not working in Fire fox i am getting null value but it is working fine in IE.

Error in query: Resource id #4??
hey guys, having a minor (i think) problem here that i havent been able to figure out. long story sh

Pspell with my own dictionary
Hello!
I've tested two cases using pspell functions.
1)
Code: $dictionary_link = pspell_new

Converting from one format to another
"I have got a date in DD/MM/YYYY but I need it in MM-DD-YYYY. Help!"

Issues: PHP Forms -Clearing
I've tried looking online before actually asking for help, but I've been looking for about the past

help retrieiving results and doing pagination
Having some trouble trying to get the results to show on more than just one page.

What is ha

wav to mp3 + goDaddy
I need to convert wav files to mp3s. From what I have found so far one way to do it is to have my PH

Issue Parsing XML into table
Hello all,

Im a bit new to php and new to phpfreaks. But thanks in advance for the help!
<

Sign up to write
Sign up now if you have flare of writing..
Login   |   Register
Follow Us
Indyaspeak @ Facebook Indyaspeak @ Twitter Indyaspeak @ Pinterest RSS



Play Free Quiz and Win Cash