sendmail.php failure to send to email address
Posted: Tue Sep 14, 2010 10:11 am
Please can you help!
I have a sendform.php which should send contact form information to an email address. I have tested using several email addresses and it works perfectly. When I add in the customers address the form does not send the email to the required address.
Is there something that I can do to fix this:
Form Code:
<input type="text" name="firstname" value="First Name..." id="firstname" />
<input type="text" name="lastname" value="Last Name..." id="lastname" />
<input type="text" name="phone" value="Phone Number..." id="phone" />
<input type="text" name="email" value="Email Address..." id="email" />
<textarea name="message" style="height: 80px;" id="message" >Your Message...</textarea>
<input type="hidden" name="to" value="sarah@bpstrategies.net" />
<input type="hidden" name="contact" value="true" />
<input type="submit" value="SUBMIT" />
</form>
I would really appreciate some help with this
Amanda
I have a sendform.php which should send contact form information to an email address. I have tested using several email addresses and it works perfectly. When I add in the customers address the form does not send the email to the required address.
Is there something that I can do to fix this:
Code: Select all
<?php
if($_POST) {
if($_POST['firstname'] && $_POST['lastname']
&& $_POST['email'] && $_POST['message'] && $_POST['to']) {
//define the receiver of the email
$to = $_POST['to'];
//define the subject of the email
$subject = 'BP Strategies Contact Form';
//define the message to be sent. Each line should be separated with \n
$message = "First name: ".$_POST['firstname'];
$message .= "\nLast name: ".$_POST['lastname'];
$message .= "\nPhone: ".$_POST['phone'];
$message .= "\nEmail: ".$_POST['email'];
if($_POST['contact']) {
$message .= "\n\nMessage: ".$_POST['message'];
//define the headers we want passed. Note that they are separated with \r\n
$headers = "From: registerform@bpstrategies.net\r\nReply-To: registerform@bpstrategies.net";
} else {
//define the headers we want passed. Note that they are separated with \r\n
$headers = "From: contactform@bpstrategies.net\r\nReply-To: contactform@bpstrategies.net";
}
//send the email
$mail_sent = @mail( $to, $subject, $message, $headers );
//if the message is sent successfully print "Mail sent". Otherwise print "Mail failed"
echo $mail_sent ? "Mail sent succesfully!" : "Mail failed! Please try again.";
}
}
?><input type="text" name="firstname" value="First Name..." id="firstname" />
<input type="text" name="lastname" value="Last Name..." id="lastname" />
<input type="text" name="phone" value="Phone Number..." id="phone" />
<input type="text" name="email" value="Email Address..." id="email" />
<textarea name="message" style="height: 80px;" id="message" >Your Message...</textarea>
<input type="hidden" name="to" value="sarah@bpstrategies.net" />
<input type="hidden" name="contact" value="true" />
<input type="submit" value="SUBMIT" />
</form>
I would really appreciate some help with this
Amanda