Hey Guys,
My email code isn't working, can anyone help?
Thanks.
<?php
if(isset($_POST['send'])){
$to = "
[email protected]" ; // change all the following to $_POST
$from = $_REQUEST['Email'] ;
$name = $_REQUEST['Name'] ;
$headers = "From: $from";
$subject = "Web Contact Data";
$fields = array();
$fields{"Name"} = "Name";
$fields{"Email"} = "Email";
$body = "We have received the following information:\n\n"; foreach($fields as $a => $b){ $body .= sprintf("%20s: %s\n",$b,$_REQUEST[$a]); }
$subject2 = "Thank you for contacting us.";
$autoreply = "<html><body><p>Dear " . $name . ",</p><p>Thank you for registering with ERB Images.</p>
<p>To make sure that you continue to receive our email communications, we suggest that you add
[email protected] to your address book or Safe Senders list. </p>
<p>In Microsoft Outlook, for example, you can add us to your address book by right clicking our address
in the
'From' area above and selecting 'Add to Outlook Contacts'
in the list that appears.</p>
<p>We look forward to you visiting the site, and can assure you that your privacy will continue to be respected at all times.</p><p>Yours sincerely.</p><p>Edward R Benson</p><p>Edward Benson Esq.<br />Founder<br />ERB Images</p><p>www.erbimages.com</p></body></html>";
$headers2 = 'MIME-Version: 1.0' . "\r\n";
$headers2 .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$headers2 .= 'From:
[email protected]' . "\r\n";
mail($from, $subject2, $autoreply, $headers2);
$send=false;
if($name == '') {$error= "You did not enter your name, please try again.";}
else {
if(!preg_match("/^[[:alnum:]][a-z0-9_.'+-]*@[a-z0-9-]+(\.[a-z0-9-]{2,})+$/",$from)) {$error= "You did not enter a valid email address, please try again.";}
else {
$send = mail($to, $subject, $body, $headers);
$send2 = mail($from, $subject2, $autoreply, $headers2);
}
if(!isset($error) && !$send)
$error= "We have encountered an error sending your mail, please notify
[email protected]"; }
}// end of if(isset($_POST['send']))
?>
<?php include("http://erbimages.com/php/doctype/index.
php"); ?>
<?php include("http://erbimages.com/php/head/index.
php"); ?>
<div class="newsletter">
<ul>
<form method="post" action="http://lilyandbenson.com/newletter/index.
php">
<li>
<input size="20" maxlength="50" name="Name" value="Name" onfocus="if(this.value==this.defaultValue) this.value='';" onblur="if(this.value=='') this.value=this.defaultValue;">
</li>
<li>
<input size="20" maxlength="50" name="Email" value="Email" onfocus="if(this.value==this.defaultValue) this.value='';" onblur="if(this.value=='') this.value=this.defaultValue;">
</li>
<li>
<input type="submit" name="send" value="Send" id="register_send">
</li>
</form>
<?php
?>
</ul>
<div class="clear"></div>
</div>
<div class="section_error">
<?php
if(isset($error))
echo '<span id="section_error">'.$error.'</span>';
if(isset($send) && $send== true){
echo 'Thank you, your message has been sent.';
}
if(!isset($_POST['send']) || isset($error))
?>
<div class="clear"></div>
</div>
</body>
</html>