Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

PHP EMAIL Problem

Options
  • 23-03-2008 4:16pm
    #1
    Closed Accounts Posts: 72 ✭✭


    hey there,
    i'm having a problem sending an email using php.

    i keep getting this error


    Warning: mail() [function.mail]: Failed to connect to mailserver at "localhost" port 25, verify your "SMTP" and "smtp_port" setting in php.ini or use ini_set() in C:\xampp\htdocs\xampp\processEmail.php on line 17


    i checked the php.ini file and SMTP = localhost
    and smtp_port = 25.

    can someone please tell me what i need to do to fix it and what code to change


    here's my php code
    <?php
    $name=$_POST['name'];
    $email=$_POST['email'];
    $subject=$_POST['subject'];
    $message=$_POST['message'];
    $name=trim($name);
    $email=trim($email);
    $subject=StripSlashes($subject);
    $message=StripSlashes($message);
    
    $toaddress='xxxxxxxxxxxr@gmail.com';
    
    mail($toaddress,$subject,$message,"From: $name <$email>");
    $name='';
    $email='';
    $subject='';
    $message='';
    echo "response=passed";
    ?>
    


Comments

  • Registered Users Posts: 3,568 ✭✭✭ethernet


    Do you have a mail server running on that machine?


  • Closed Accounts Posts: 72 ✭✭fatjose101


    ethernet wrote: »
    Do you have a mail server running on that machine?


    that could be it alright. what would be the best mail server to get? and would there be anymore configuration once the mail server is set up?


  • Registered Users Posts: 9,579 ✭✭✭Webmonkey




  • Closed Accounts Posts: 72 ✭✭fatjose101


    Webmonkey wrote: »


    I installed php smtp server for windows but when i try sending the mail i get this error

    Warning: mail() [function.mail]: SMTP server response: 515 can not connect to gsmtp147.google.com ! ! in C:\xampp\htdocs\xampp\processEmail.php on line 14
    response=passed

    PLEASE CAN SOMEBODY HELP ME!


  • Registered Users Posts: 1,045 ✭✭✭Bluefrog


    Looks like your mail is being sent on to google but they don't operate on port 25 as far as I know. They also use authentication so they're not the best choice for this - you could simply put the smtp server of your ISP in php.ini.


  • Advertisement
  • Registered Users Posts: 2,534 ✭✭✭FruitLover


    Bluefrog wrote: »
    Looks like your mail is being sent on to google but they don't operate on port 25 as far as I know. They also use authentication so they're not the best choice for this

    You're thinking of outbound mail sent from clients, their inbound servers have to accept mail on port 25.

    OP, for some reason your mail server is trying to connect to a lower-priority gmail server (one which isn't currently accepting connections). What it should be doing is trying the highest priority server first (which is accepting, I just checked), then go down the list if it doesn't get a successful connection. Looks like your mail server isn't set up correctly.

    Edit: Just thought of another possibility - your ISP might be blocking outbound SMTP connections (not uncommon these days, due to the popularity of spamming worms/trojans). This would cause it to go through all of gmail's MX records before reporting the last one as problematic. If this is the case, you'll need to either configure your mail server to forward all mails to your ISP's mail relay, or put the ISP relay into your php.ini as per Bluefrog's suggestion.


  • Closed Accounts Posts: 72 ✭✭fatjose101


    thanks guys. i'm using the smtp server of my ISP now and it seems to be working fine. thanks for all your help :)


Advertisement