PHP Mail function not working with XAMMP?

Discussion in 'PHP' started by pabin2009, Sep 2, 2009.

  1. #1
    Hi,

    I've tried EasyPHP and normal PHP configuration and mail function worked well, but now I have XAMMP and my mail function is not working anymore.

    I've installed the full package of XAMMP succesfully.

    Error I got after trying to send: We do not relay non-local mail, sorry.

    Have someone any ideas? I've tried to put my From: -header to the following without luck:
    me@localhost
    me@example.com
    localhost
    *MYIP*

    Has someone idea on what is non-local mail? So I can not mail to anywhere else than my own cpu??

    thank you
     
    pabin2009, Sep 2, 2009 IP
  2. premiumscripts

    premiumscripts Peon

    Messages:
    1,062
    Likes Received:
    48
    Best Answers:
    0
    Trophy Points:
    0
    #2
    premiumscripts, Sep 2, 2009 IP
  3. tenev

    tenev Active Member

    Messages:
    322
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    95
    #3
    you can still use SMTP with XAMPP (atleast i do)
    you can use phpmailer , its free and supports SMTP

    here is a function by me , so its gona be easier :), i use it for my websites

    
    function mailuser($mailsubject,$mailbody,$receiveremail,$replyto)
    {
    	include("phpmailer/class.phpmailer.php"); // include phpmailer class! you may use different folder...
            //simple stupid function by tenev aka penihop
    	$mail = new PHPMailer();
    	$mail->IsSMTP();                    // set mailer to use SMTP
    	$mail->Host = "mail.example.com";        // specify main and backup server
    	$mail->SMTPAuth = true;              // turn on SMTP authentication
    	$mail->Username = "ex@example.com";     // SMTP username
    	$mail->Password = "examplepassword";     // SMTP password
    	$mail->From = "ex@example.com";         //do NOT fake header.
    	$mail->FromName = $replyto;          // from which email adress
    	$mail->AddAddress($receiveremail);         // to which email address
    	$mail->AddReplyTo($replyto, "Please do not reply to this email!"); //optional, spcify to which email they will reply 
    
    	$mail->Subject	=	$mailsubject;
    	$mail->Body		=	$mailbody;
    	
    	$retcode=false;
    	if(!$mail->Send())
    	{
    	   echo $mail->ErrorInfo; // showerror
    	   $retcode=$mail->ErrorInfo;
    	}
    	else
    	{
    	   //echo "email was sent"; // show success
    	   $retcode=true;
    	}
    	return $retcode; // will return true if email was send
    }
    PHP:

    and here is how you are going to use it :


    
    
    $mailbody=" Hello, 
    bla bla bla b la. so blablalba (xD) bla bloa...
    bla bla bla blablalbal
    lalaallalal blabblalbla
    Thanks, the support.
    "; // email content
    			
    $receiveremail="example@hotmail.com"; // to who
    $replymail="ex@example.com"; // user reply to this email
    $subject="we are emailng you because ?"; // why we are emailing him :@?
    			
    if(mailuser($subject,$mailbody,$receiveremail,$replymail))
    {
     echo("Email was send!");
    }
    
    
    PHP:
    don't forget to download phpmailer from here http://phpmailer.worxware.com/
    works Perfectly with XAMPP and PHP 4/5/6
     
    Last edited: Sep 2, 2009
    tenev, Sep 2, 2009 IP