PHP Mailing problem

Discussion in 'PHP' started by ByteCoder, Aug 7, 2010.

  1. #1
    Hello,
    I'm hosting my site on Domain.com (the Deluxe plan).

    I'm having a problem with sending emails with this code :

    <?php
    	require_once "Mail.php";
    	
    	$msg = $_GET['msg'];
    	$username = $_GET['paypal'];
    	$name = $_GET['name'];
    
    	$to = 'themilliardaire@msn.com';  
    	
    	$subject = 'Site Contact Form';  
    	$message = $name. ' wants to contact you.
    			
    	He send the following message : ' . $msg . '
    			
    	His username is : ' . $username;  
    	$header .= "Reply-To: Site <info@Site.com>\r\n"; 
    	$header .= "Return-Path: Site<info@Site.com>\r\n"; 
    	$header .= "From: Site<info@Site.com>\r\n"; 
    	$header .= "Organization: Site\r\n"; 
    	$header .= "Content-Type: text/plain\r\n"; 
    			  
    	$res = mail($to, $subject, $message, $header);
    	
    	if($res)
    	{
    		echo "OK";
    	}
    	else
    	{
    		echo "BAD";
    	}
    	
    ?>
    Code (markup):
    I either get a "BAD" or nothing at all which is really weird.
    Any help?
     
    ByteCoder, Aug 7, 2010 IP
  2. Rainulf

    Rainulf Active Member

    Messages:
    373
    Likes Received:
    12
    Best Answers:
    0
    Trophy Points:
    85
    #2
    There's nothing wrong with that code. Everything works perfectly. I suggest that you check inside Mail.php or those $_GET or if you're even allowed to use PHP mail in your webhost. :)
     
    Rainulf, Aug 7, 2010 IP
  3. danx10

    danx10 Peon

    Messages:
    1,179
    Likes Received:
    44
    Best Answers:
    2
    Trophy Points:
    0
    #3
    Check your host hasn't disabled the mail() function (which believe it or not some hosts do - namely free as a measure to prevent spam) either via php.ini (disabled_functions) or using php -> function_exists()

    Furthermore add error_reporting(E_ALL); at the top of your code, to see if theirs any underlying errors.

    Let me know how that goes, also include any errors in your next reply if apparent.

    PS: On a side note you may want to validate and/or clean your inputs (strip potential headers)
     
    danx10, Aug 8, 2010 IP
  4. strgraphics

    strgraphics Active Member

    Messages:
    710
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    53
    #4
    your code is good.., think its your hosting issue.
     
    strgraphics, Aug 9, 2010 IP
  5. virginmind

    virginmind Peon

    Messages:
    1
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Hi Grunt,

    Ur Sending mail coding r perfect, some problem in ur domain So u check Ur mail file in your web host


    Virginmind Technologies
     
    virginmind, Aug 9, 2010 IP