Failed to connect mail server

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • mmr315
    New Member
    • Aug 2007
    • 25

    Failed to connect mail server

    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:\Apache2.2\ht docs\mail.php on line 7


    i changed in php.ini

    SMTP=192.168.1. 50
    smtp_port=25

    ;for win32 only
    sendmail_from = email_removed@y our_domain.com

    here 192.168.1.50 is the ip address of internal mail server


    i wrote code like this

    =============== ==
    [CODE=php] <?php
    $to = "email_removed@ your_domain.com ";
    $subject = "Test mail";
    $message = "Hello! This is a simple email message.";
    $from = "mahesh.reddy@s hantasoft.com";
    $headers = "From: $from";
    mail($to,$subje ct,$message,$he aders);
    echo "Mail Sent.";
    ?>[/CODE]


    please help me

    thanks & regards

    Madhu
    Last edited by ak1dnar; Aug 16 '07, 09:42 AM. Reason: Added CODE tags/Email Address Removed
  • SamithaFernando
    New Member
    • Aug 2007
    • 8

    #2
    hi
    i guess u hav to set the path to your mail server isn't functioning .
    I had this same problem but after setting the path correctly it worked. Also make sure that some mail server's need authentication. then u have to authenticate by using valid user name and a password. to do that u can write a simple code like this.
    Eg:-
    $headers = array ('From' => $email,
    'To' => $to,
    'Subject' => $subject);
    $smtp = Mail::factory(' smtp',
    array ('host' => $host,
    'auth' => true,
    'username' => $username,
    'password' => $password));

    $mail = $smtp->send($to, $headers, $message);

    Comment

    • Nert
      New Member
      • Nov 2006
      • 64

      #3
      Originally posted by mmr315
      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:\Apache2.2\ht docs\mail.php on line 7


      i changed in php.ini

      SMTP=192.168.1. 50
      smtp_port=25

      ;for win32 only
      sendmail_from = mahesh.reddy@sh antasoft.com

      here 192.168.1.50 is the ip address of internal mail server
      Try to change the value of your SMTP in your php.ini, put the domain name of your mail server, for example " mail.example.co m "

      Comment

      • ak1dnar
        Recognized Expert Top Contributor
        • Jan 2007
        • 1584

        #4
        • Please Do not post your email address with your code snippets when posting in Technical Forums like Php-Forum. You may better to use some sample email address or domain name when it needs.
        • Please Use the [code=xxx] Tags.

        Comment

        • ak1dnar
          Recognized Expert Top Contributor
          • Jan 2007
          • 1584

          #5
          Hi Madu,
          You Have to Configure your php.ini File with a real SMTP server value.

          Comment

          Working...