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

Structure Question - One Table or One Table Per Record Set?
I have a web app (mySQL and PHP) which allows people to create an item with up to 200 records which

Header is not working in IE
Hi ! header function is not working in IE but it works in FF, Safari, Chrome. any help please. :

Beginner question regarding Array's
Hi everyone, the page im working on has an array of variable at the top...

Code: $define_li

newbie question about multiple queries
hi everyone,
I'm sorry to ask such a basic question, but I'm young and trying to learn php on my

PHP mail() with images
I'm trying to get images to send along with my HTML e-mail sent through PHP mail(). I only tried vie

restricting another login once you logout
Hello,

how can I restrict a page from login authenticating against info in a MySQL DB for a s

Convert Binary String to Decimal
Trying to Get:
Decimal: 305419896

Out of:
Binary String: xV4

Call Screen statement Error
Dear Experts,

is there any setting that needs to be done before creating any dialog progr

Chat Box in PHP
I was thinking in doing a Chat Box in PHP. For that I would use a form with two fields, Nick and Mes

Using mysql_real_escape_string for displayed content
On my website users can input data into a textarea and it will store it in the mysql database. But,

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