Closed Thread
Results 1 to 5 of 5

Thread: Problem sending mail from php

  1. #1
    orejano11-us28 is offline x10Hosting Member orejano11-us28 is an unknown quantity at this point
    Join Date
    Aug 2011
    Posts
    3

    Problem sending mail from php

    Hi i'm new to this hosting, i'm learning php and need to send mails for a project but i can't send mail using php's mail() function
    i tried using the code that descalzo posted in another thread

    Code:
    <?php 
    
    
    //  TEST OF THE MAIL SYSTEM USING PHP mail() 
    
    date_default_timezone_set('America/Los_Angeles'); 
    echo date('l jS \of F Y h:i:s A');  
    echo "\n"; 
    
    $from = "myX10cPanelName@myX10domain.x10.bz"; 
    $to="myGMAILaccount@gmail.com";  
    
    
    $mailbody="Test message sent (PST): \n" . date('l jS \of F Y h:i:s A'); 
    $subject="Test of PHP mail()" ; 
    
    $headers = "Content-type: text/plain; charset=windows-1251 \r\n"; 
    $headers .= "From: $from\r\n"; 
    $headers .= "Reply-To: $from\r\n"; 
    $headers .= "MIME-Version: 1.0\r\n"; 
    $headers .= "X-Mailer: PHP/" . phpversion(); 
    
    $resp = mail($to, $subject, $mailbody, $headers); 
    
    if( $resp ){ 
        $outcome = "Mail sent" ; 
    } else { 
        $outcome = "Mail not sent"; 
    } 
    
    print "\nThe mail system said: $outcome\n\n" ; 
    exit();


    But it doesn't work for me

    i set up a mail account to use with this script
    also have selected Local Mail Exchanger in MX Entry in my CPanel
    i'm sending mails to yahoo, spamavert and to my work accounts

    i have tried using phpMailer and this other code
    Code:
    
    require("PHPMailer_5.2.0/class.phpmailer.php");
    $mail = new PHPMailer();
    
    $mail->From = "your_emaila_ccount@your_domain.com";
    $mail->FromName = "Admin";
    $mail->AddAddress("examle@example.com"); // This is the adress to witch the email has to be send. 
    $mail->Subject = "An HTML Message";
    $mail->IsHTML(true); // This tell's the PhPMailer that the messages uses HTML.
    $mail->Body = "Hello, <b>my friend</b>! \n\n This message uses HTML !";
    $mail->AltBody = "Dear Sir/Madam \n\n This message uses HTML, but your email client did not support it !";
    
    if(!$mail->Send()) // Now we send the email and check if it was send or not.
    {
       echo 'Message was not sent.';
       echo 'Mailer error: ' . $mail->ErrorInfo;
    }
    else
    {
       echo 'Message has been sent.';
    }


    and had no luck either, so if someone could help me i will be very happy

    Thanks and excuse my english


    PS: i forgot to mention that the mails are getting out, i'm getting the "Mail delivery failed: returning message to sender" mails in my account inbox (in the domain main account)

    This message was created automatically by mail delivery software.

    A message that you sent could not be delivered to one or more of its
    recipients. This is a permanent error. The following address(es) failed:

    pepe@spamavert.com
    SMTP error from remote mail server after RCPT TO:<pepe@spamavert.com>:
    host 10.33.251.248 [10.33.251.248]: 553 sorry, that domain isn't in my list of allowed rcpthosts (#5.7.1)

    ------ This is a copy of the message, including all the headers. ------

    Return-path: <jz@lotus.x10hosting.com>
    Received: from jz by lotus.x10hosting.com with local (Exim 4.69)
    (envelope-from <jz@lotus.x10hosting.com>)
    id 1QwDYA-0005bu-GJ
    for pepe@spamavert.com; Wed, 24 Aug 2011 09:31:22 -0400
    To: pepe@spamavert.com
    Subject: Test of PHP mail()
    Content-type: text/plain; charset=windows-1251
    From: webmaster@empresa.x10.mx
    Reply-To: webmaster@empresa.x10.mx
    MIME-Version: 1.0
    X-Mailer: PHP/5.3.6
    Message-Id: <E1QwDYA-0005bu-GJ@lotus.x10hosting.com>
    Date: Wed, 24 Aug 2011 09:31:22 -0400

    Test message sent (PST):
    Wednesday 24th of August 2011 06:31:22 AM
    Last edited by orejano11-us28; 08-24-2011 at 09:17 AM.

  2. #2
    descalzo's Avatar
    descalzo is offline Grim Squeaker descalzo has a brilliant futuredescalzo has a brilliant futuredescalzo has a brilliant future
    Join Date
    Jul 2009
    Location
    Ankh-Morpork
    Posts
    7,635

    Re: Problem sending mail from php

    SMTP error from remote mail server after RCPT TO:<pepe@spamavert.com>:
    host 10.33.251.248 [10.33.251.248]: 553 sorry, that domain isn't in my list of allowed rcpthosts (#5.7.1)
    Apparently they are rejecting the email because the sending domain isn't on their list of allowed senders.

    Considering the domain you are sending to, do you have to configure it to accept specific domains?

    The problem is apparently on spamavert's end, not x10hosting's.
    Nothing is always absolutely so.

  3. #3
    orejano11-us28 is offline x10Hosting Member orejano11-us28 is an unknown quantity at this point
    Join Date
    Aug 2011
    Posts
    3

    Re: Problem sending mail from php

    Thanks for four reply but the server response is the same even if i send to different domains (i tried yahoo.com, spamavert.com, gmail.com and my employers email)

  4. #4
    Corey's Avatar
    Corey is offline VPS Migration Professional Corey is a glorious beacon of lightCorey is a glorious beacon of light
    Join Date
    Dec 2004
    Location
    Northfield, NH
    Posts
    17,151

    Re: Problem sending mail from php

    Try now
    Corey Arbogast | CEO
    █ 888-X10-9668 - corey[@]x10hosting.com
    x10Hosting - Giving Away Hosting Since 2004
    Premium Hosting | VPS Services

  5. #5
    orejano11-us28 is offline x10Hosting Member orejano11-us28 is an unknown quantity at this point
    Join Date
    Aug 2011
    Posts
    3

    Re: Problem sending mail from php

    It's working now, thank you!

Closed Thread

Similar Threads

  1. problem with sending mail to me.com
    By Kichi in forum Free Hosting
    Replies: 2
    Last Post: 02-18-2011, 12:25 PM
  2. Problem Sending an E-mail. Help me.
    By edyel180 in forum Free Hosting
    Replies: 1
    Last Post: 01-01-2010, 04:08 PM
  3. Problem sending mail
    By utharnl in forum Free Hosting
    Replies: 6
    Last Post: 08-11-2009, 07:04 PM
  4. Mail sending problem
    By xav0989 in forum Free Hosting
    Replies: 2
    Last Post: 07-17-2008, 04:41 AM
  5. problem in sending mail
    By idrees in forum Free Hosting
    Replies: 2
    Last Post: 02-08-2008, 01:39 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
x10hosting free hosting for the masses
dedicated servers