Mail Function doesnot work

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • anandaraman
    New Member
    • Feb 2007
    • 8

    #1

    Mail Function doesnot work

    Hi all, i want to send mail through php coding.but error displays. i am working in windows environment. please help..

    PHP Coding:

    <?php
    $to = "anandh@yahoo.c om";
    $subject = "Example";
    $txt = "Test a Mail Function!";
    $headers = "From: karthick@rediff mail.com";
    mail($to,$subje ct,$txt,$header s);
    ?>


    Error is:

    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:\Program Files\xampp\htd ocs\textexample \mailfn.php on line 8

    hoew to rectify this. please tell in detail...
  • ak1dnar
    Recognized Expert Top Contributor
    • Jan 2007
    • 1584

    #2
    There is No Problem in with the Coding.
    Problem is with your php.ini file.

    You have to set Your SMTP provider Address and PORT.
    This File is Located at Windows folder.

    Locate and uncomment SMTP settings with Your Values.

    Code:
    [mail function]
    ; For Win32 only.
    SMTP = your.ISP.com
    smtp_port = 25

    Comment

    • ronverdonk
      Recognized Expert Specialist
      • Jul 2006
      • 4259

      #3
      Originally posted by ajaxrand
      There is No Problem in with the Coding.
      Problem is with your php.ini file.

      You have to set Your SMTP provider Address and PORT.
      This File is Located at Windows folder.

      Locate and uncomment SMTP settings with Your Values.

      Code:
      [mail function]
      ; For Win32 only.
      SMTP = your.ISP.com
      smtp_port = 25
      and also: the initialization of 'sendmail_from'
      Code:
      ; For Win32 only.
      sendmail_from = yourname@yoursystem.com
      Ronald :cool:

      Comment

      • Atli
        Recognized Expert Expert
        • Nov 2006
        • 5062

        #4
        Originally posted by ronverdonk
        and also: the initialization of 'sendmail_from'
        Code:
        ; For Win32 only.
        sendmail_from = yourname@yoursystem.com
        Ronald :cool:
        Adding a "From: me@mydomain.me" to the headers will also work.

        Comment

        • ronverdonk
          Recognized Expert Specialist
          • Jul 2006
          • 4259

          #5
          Originally posted by Atli
          Adding a "From: me@mydomain.me" to the headers will also work.
          Sure does.

          Ronald :cool:

          Comment

          • bb nicole
            New Member
            • Jan 2007
            • 127

            #6
            sorry, i still cant solve the problem of my forget password, i have install and open the free smtp server, when i send the mail, it have a warning as below...
            Warning: mail(): SMTP server response: 503 in C:\Apache2\Apac he2\htdocs\forg otPassword.php on line 25
            Error sending email
            What should i do now??? thanks..
            n i try to click on the start menu, run, den type 'telnet localhost 25'
            it show me:
            220 localhost

            Comment

            • ak1dnar
              Recognized Expert Top Contributor
              • Jan 2007
              • 1584

              #7
              Since you are accessing a remote SMTP server like smtp.gmail.com,
              Your Server should connect to the Internet.Just Check it.Otherwise you can't send the mails from Local intranet to Internet.

              Post your SMTP settings here.

              Comment

              • bb nicole
                New Member
                • Jan 2007
                • 127

                #8
                Originally posted by ajaxrand
                Since you are accessing a remote SMTP server like smtp.gmail.com,
                Your Server should connect to the Internet.Just Check it.Otherwise you can't send the mails from Local intranet to Internet.

                Post your SMTP settings here.
                [mail function]
                ; For Win32 only.
                SMTP = localhost
                smtp_port = 25


                ; For Win32 only.
                sendmail_from = me@localhost.co m
                Emm.. wat should i do?? Thanks..

                Comment

                • ak1dnar
                  Recognized Expert Top Contributor
                  • Jan 2007
                  • 1584

                  #9
                  Originally posted by bb nicole
                  [mail function]
                  ; For Win32 only.
                  SMTP = localhost
                  smtp_port = 25


                  ; For Win32 only.
                  sendmail_from = me@localhost.co m
                  Emm.. wat should i do?? Thanks..
                  Dear Friend,
                  Have you configured this localhost as a SMTP server.I don't think so.
                  Try to find out real SMTP service provider.Normal ly for the SMTP facility you can use most of the email service providers.Becau se SMTP is Not like POP.
                  If you are running from a home-based server supply your ISP's mailserver as your SMTP host.


                  smtp.mail.yahoo .com
                  25
                  smtp.gmail.com
                  465 or 587

                  Some times You need the Authentication also.....

                  Comment

                  Working...