Unable to connect to localhost to send SMTP mail.

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Martin84
    New Member
    • Jun 2007
    • 11

    Unable to connect to localhost to send SMTP mail.

    Hi all, im creating a mail form in PHP and I got back the following message in when testing:

    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:\wamp\www\ema il_script.php on line 38#

    As you can tell from the localhost reference I am using a server on my own computer for testing purposes.Is this the only reason why it wont work or can it actually be fixed by changing the port settings in the php.ini file? If so does anyone have any idea how I would do this, I dont know anything about port numbers so im stumped.

    In reference to the latter part of the error message I substituted the 'mail' command for the ini_set() reference but just got a parse error on line 38# message.

    Thanks in advance,

    Martin
  • pbmods
    Recognized Expert Expert
    • Apr 2007
    • 5821

    #2
    Changed thread title to give a better description of the problem.

    Try using 127.0.0.1 instead of localhost.

    Comment

    • ronnil
      Recognized Expert New Member
      • Jun 2007
      • 134

      #3
      have you setup an SMTP server on your localhost? if not, you will need to give it the same settings as you do with your regular email account for outgoing mail.

      I suppose there are sort of free SMTP-servers out there for testing purposes but got no idea where. You can however also setup your personal testing server for use with php only, this way you can actually keep the mails from ever being send out but you will be able to monitor it anyway.

      the "localhost" setting in php.ini is standard, so don't count on that.

      Comment

      • Motoma
        Recognized Expert Specialist
        • Jan 2007
        • 3236

        #4
        What operating system are you using?

        Comment

        • epots9
          Recognized Expert Top Contributor
          • May 2007
          • 1352

          #5
          hey Martin84,

          i tried the same thing and got the same error as u, what u should do is use the same stmp that your ISP gives u, worked for me.

          Comment

          • Martin84
            New Member
            • Jun 2007
            • 11

            #6
            I used WAMP5 to set up apache, php, mysql without configuring anything, I dont think this has set up an SMTP service as well. Do you hnow how you would go about scripting to give it (localhost)the same settings as the regular email account for outgoing mail? Im using a yahoo service by the way, if that has any relevance.

            I tried the 127.0.0.1 thing but it didnt work, seem as its just another way of writing localhost

            Comment

            • Martin84
              New Member
              • Jun 2007
              • 11

              #7
              Im using windows xp (home edition). Hi Epots9, how do you find the stmp that the ISP gives and how would you set it up? Im a complete novice when it comes to dealing with servers, hosts etc

              Comment

              • Motoma
                Recognized Expert Specialist
                • Jan 2007
                • 3236

                #8
                Typically the easiest solution on a Windows install is to download and configure one of the various free SMTP servers around.

                Comment

                • epots9
                  Recognized Expert Top Contributor
                  • May 2007
                  • 1352

                  #9
                  to find your ISP's smtp, go to their site and u'll have to search or read the FAQ for it, try looking for "setup outlook", if they have any topics it will give u the pop address to use and the smtp address to use. just put the smtp address in the php.ini

                  or post the URL to your ISP's site (or name of ISP) and i'll try and find it for u

                  good luck

                  Comment

                  Working...