mail() fails to connect to SMTP server

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • syam
    New Member
    • Dec 2006
    • 28

    mail() fails to connect to SMTP server

    Hai Friends..

    I am using the simple form of mail() function. I am giving the code down.I am writing code for mail sending function in a feedback form. The mails are always sent to the variable $this->to_mail in the code and the visitors are putting their mail id in $this->from_mail in code.

    [code=php]
    if(isset($_POST['sub']))
    {
    echo "The Post is not empty";
    $this->from_mail = $_POST['frm_mail_id'];//
    $this->mail_header = "From: $this->from_mail";
    echo "The Header is : ".$this->mail_header;
    echo "The Sender's Mail Id is : ".$this->from_mail;
    $this->to_mail = "syammohan_ch@y ahoo.com";
    $this->subject = $_POST['subject'];
    echo "The Subject is : ".$this->subject;
    $this->message = $_POST['message'];
    echo "The Message is : ".$this->message;
    mail($this->to_mail,$thi s->subject,$thi s->message,$thi s->mail_header) ;[/code]


    but i am getting the error saying that

    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()

    my php.ini settings are
    Code:
    [mail function]
    ; For Win32 only.
    SMTP = localhost
    smtp_port = 25
    
    ; For Win32 only.
    sendmail_from = me@example.com
    
    
    
    thanks in advance..
    			//$this->doMail();
    			
    		}
    [Please use CODE tags when posting source code. Thanks! --pbmods]
  • ronnil
    Recognized Expert New Member
    • Jun 2007
    • 134

    #2
    you need to configure php to a proper SMTP server. By default the server is set to localhost.

    Go into your e-mail program, and find out what SMTP server you send your regular e-mails through, then insert this information in php.ini.

    You can ofcourse also setup an SMTP server on your localhost for testing needs. I'm afraid I don't have any links to one atm.

    Comment

    • syam
      New Member
      • Dec 2006
      • 28

      #3
      Please tell me how do i find out my smtp server name

      Comment

      • ronnil
        Recognized Expert New Member
        • Jun 2007
        • 134

        #4
        It depends on which e-mail program you use. But basically you can see it under account settings.

        Comment

        • kovik
          Recognized Expert Top Contributor
          • Jun 2007
          • 1044

          #5
          You may want to try Swiftmailer. Very easy and has docs on SMTP connection.

          Comment

          • pbmods
            Recognized Expert Expert
            • Apr 2007
            • 5821

            #6
            Changed thread title to better describe the problem (did you know that threads whose titles contain phrases such as 'please help' actually get FEWER responses?).

            Comment

            Working...