PHP Contact Form Not Validating Or Sending
Ok...so I grabbed this PHP contact form from a combination of a few different websites and from a predecessor. I've been wrestling with it for hours and can't figure it out. In al
Solution 1:
You are missing a ;
at the end of
$regex = '/^[_a-z0-9-]+(\.[_a-z0-9-]+)@[a-z0-9-]+(\.[a-z0-9-]+)(\.[a-z]{2,3})$/'
Your From
, Reply-to
, and X-Mailer
syntax errors could be caused by switching between '
and "
in $headers
$headers = 'From: '.$email."\r\n".
'Reply-To: '.$email."\r\n" .
'X-Mailer: PHP/' . phpversion();
try changing to -
$headers = "From: ".$email."\r\n";
$headers .= "Reply-To: ".$email."\r\n";
$headers .= "X-Mailer: PHP/" . phpversion();
Solution 2:
Since regex solution has been given by Sean,
Here is my previous project regex I used,
$regex= "/^[\.a-z0-9_\-]+[@][a-z0-9_\-]+([.][a-z0-9_\-]+)+[a-z]{1,4}$/i";
This is another alternative for PHP mailing, you will need to download phpmailer plugin in order for this mailing to work.
<?php
// mail config start
$emailAddress = 'youremailhere';
$replyAdress ='yourreceipientemailhere';
$replyName = 'yourreceipientname';
$msgSubject= 'yoursubjecthere';
// mail config end
// Include the class,
require "phpmailer/class.phpmailer.php";
//Type your message here:
$msg = 'blablayourmessagehere';
//The mailing process begins!!
$mail = new PHPMailer();
$mail->IsMail();
$mail->AddReplyTo($replyAdress, $replyName);
$mail->AddAddress($emailAddress);
$mail->SetFrom($replyAdress, $replyName);
$mail->Subject = "New: ".$replyName." have sent a ".$msgSubject." message";
$mail->MsgHTML($msg);
$mail->Send();
?>
Post a Comment for "PHP Contact Form Not Validating Or Sending"