kittyshe911 Posted July 21, 2010 Share Posted July 21, 2010 Hi there! I am a mere Web designer trying to utilize this submit.php file in conjunction with my contact form and yet it is not sending the message to the email that is indicated... Here is the script: <?php /* config start */ $emailAddress = '[email protected]'; /* config end */ require "phpmailer/class.phpmailer.php"; session_name("fancyform"); session_start(); foreach($_POST as $k=>$v) { if(ini_get('magic_quotes_gpc')) $_POST[$k]=stripslashes($_POST[$k]); $_POST[$k]=htmlspecialchars(strip_tags($_POST[$k])); } $err = array(); if(!checkLen('name')) $err[]='The name field is too short or empty!'; if(!checkLen('email')) $err[]='The email field is too short or empty!'; else if(!checkEmail($_POST['email'])) $err[]='Your email is not valid!'; if(!checkLen('subject')) $err[]='You have not selected a subject!'; if(!checkLen('message')) $err[]='The message field is too short or empty!'; if((int)$_POST['captcha'] != $_SESSION['expect']) $err[]='The captcha code is wrong!'; if(count($err)) { if($_POST['ajax']) { echo '-1'; } else if($_SERVER['HTTP_REFERER']) { $_SESSION['errStr'] = implode('<br />',$err); $_SESSION['post']=$_POST; header('Location: '.$_SERVER['HTTP_REFERER']); } exit; } $msg= 'Name: '.$_POST['name'].'<br /> Email: '.$_POST['email'].'<br /> IP: '.$_SERVER['REMOTE_ADDR'].'<br /><br /> Message:<br /><br /> '.nl2br($_POST['message']).' '; $mail = new PHPMailer(); $mail->IsMail(); $mail->AddReplyTo($_POST['email'], $_POST['name']); $mail->AddAddress($emailAddress); $mail->SetFrom($_POST['email'], $_POST['name']); $mail->Subject = "A new ".mb_strtolower($_POST['subject'])." from ".$_POST['name']." | contact form feedback"; $mail->MsgHTML($msg); $mail->Send(); unset($_SESSION['post']); if($_POST['ajax']) { echo '1'; } else { $_SESSION['sent']=1; if($_SERVER['HTTP_REFERER']) header('Location: '.$_SERVER['HTTP_REFERER']); exit; } function checkLen($str,$len=2) { return isset($_POST[$str]) && mb_strlen(strip_tags($_POST[$str]),"utf-8") > $len; } function checkEmail($str) { return preg_match("/^[\.A-z0-9_\-\+]+[@][A-z0-9_\-]+([.][A-z0-9_\-]+)+[A-z]{1,4}$/", $str); } ?> :'( What am I doing wrong??? Link to comment https://forums.phpfreaks.com/topic/208467-please-help-my-php-contact-form-will-not-deliver-properly/ Share on other sites More sharing options...
gwolgamott Posted July 21, 2010 Share Posted July 21, 2010 what's it sending instead? Link to comment https://forums.phpfreaks.com/topic/208467-please-help-my-php-contact-form-will-not-deliver-properly/#findComment-1089277 Share on other sites More sharing options...
kittyshe911 Posted July 21, 2010 Author Share Posted July 21, 2010 Nothing, when the contact form is complete and "submit" is clicked, a thank you message returns... nothing is sent to the email. Link to comment https://forums.phpfreaks.com/topic/208467-please-help-my-php-contact-form-will-not-deliver-properly/#findComment-1089280 Share on other sites More sharing options...
gwolgamott Posted July 22, 2010 Share Posted July 22, 2010 Try to simplify it some with a straight mail() function then work away from it slowly with tests. I don't have time today, otherwise I'd take a stab at it, but I'd first take a few steps back do a hardcoded mail() and work back from that and integrate it a piece at the time in your function. $to = "[email protected]"; $subject = "Test mail"; $message = "Hello! This is a simple email message."; $from = "[email protected]"; $headers = "From: $from"; mail($to,$subject,$message,$headers); Link to comment https://forums.phpfreaks.com/topic/208467-please-help-my-php-contact-form-will-not-deliver-properly/#findComment-1089564 Share on other sites More sharing options...
kittyshe911 Posted July 23, 2010 Author Share Posted July 23, 2010 Much appreciated! I will definitely give it a try! Link to comment https://forums.phpfreaks.com/topic/208467-please-help-my-php-contact-form-will-not-deliver-properly/#findComment-1090186 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.