Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 8 of 8
  1. #1
    New Coder
    Join Date
    Jan 2012
    Posts
    40
    Thanks
    8
    Thanked 0 Times in 0 Posts

    Emails Not Sending

    Hi, my contact form does not send the messages to a certain email as it is supposed to. I have all the files and the right paths which connect them all and I am running PHP V5 on my server but it still doesn't work. My website is eagleview.it and if you go to the contact tab and under the source click the submit.php file you can see a error message for what seems to be the wrong file path but everything is actually right. This is what the submit.php file is supposed to be:

    Code:
    <?php
    
    /* config start */
    
    $emailAddress = 'xxxxx@hotmail.com';
    
    /* config end */
    
    
    require "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);
    }
    
    ?>
    Any suggestions on how to fix this? Thanks!

  • #2
    Master Coder
    Join Date
    Jun 2003
    Location
    Cottage Grove, Minnesota
    Posts
    9,549
    Thanks
    8
    Thanked 1,095 Times in 1,086 Posts
    It looks like you disabled right-click (using javascripting) so we can't view the HTML source.
    I'm not taking the time to turn off my javascripting so I can see your HTML ... sorry.

  • #3
    Senior Coder
    Join Date
    Feb 2011
    Location
    Your Monitor
    Posts
    4,476
    Thanks
    63
    Thanked 538 Times in 525 Posts
    Quote Originally Posted by mlseim View Post
    I'm not taking the time to turn off my javascripting so I can see your HTML ... sorry.
    Yet you frequently expect people to take their time trying to understand your php code that isn't highlighted because you refuse to take the time to use the [php] tags!

    Pot, Kettle?
    I can't really think of anything to write here now...

  • #4
    Master Coder
    Join Date
    Jun 2003
    Location
    Cottage Grove, Minnesota
    Posts
    9,549
    Thanks
    8
    Thanked 1,095 Times in 1,086 Posts
    Sorry ...
    I promise not to post any more PHP scripts on this forum in the future ... my bad.


    .

  • #5
    Senior Coder
    Join Date
    Feb 2011
    Location
    Your Monitor
    Posts
    4,476
    Thanks
    63
    Thanked 538 Times in 525 Posts
    Sheesh I was only messing about..
    I can't really think of anything to write here now...

  • #6
    Senior Coder
    Join Date
    Feb 2011
    Location
    Your Monitor
    Posts
    4,476
    Thanks
    63
    Thanked 538 Times in 525 Posts
    @kamaro: Your use of $mail->send(); returns a boolean. Therefore you should at least be testing it like this:

    PHP Code:
    if(!$mail->Send())
       {
       echo 
    "Mailer Error: " $mail->ErrorInfo;
       }
    else
       {
       echo 
    "Message sent!";
       } 
    I can't really think of anything to write here now...

  • #7
    Master Coder
    Join Date
    Jun 2003
    Location
    Cottage Grove, Minnesota
    Posts
    9,549
    Thanks
    8
    Thanked 1,095 Times in 1,086 Posts
    @tango ...
    I know .. I figured you were just kidding ...

    It's just bad timing, that's all.

    You didn't know that I have been PM'd in the past couple of months
    with comments that some of the scripting I've been posting is inefficient,
    and not secure. So I'm a bit nervous about posting things. My goal is to
    help out, and I always mention that I'm not a "professional programmer",
    which is certainly the case. I try not to take this stuff too seriously, but
    it seems others on here do this for a professional career, and I'm just
    "setting them back" ... correcting my mistakes is wasting their time.

  • #8
    Senior Coder
    Join Date
    Feb 2011
    Location
    Your Monitor
    Posts
    4,476
    Thanks
    63
    Thanked 538 Times in 525 Posts
    mlseim - PM me when you get a chance, not really the best of places to let out your emotions in this thread. PM me we'll chat.

    Tango
    I can't really think of anything to write here now...


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •