Failed to connect to mailserver error in mail() function

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Dipen Mehta
    New Member
    • Jun 2011
    • 16

    Failed to connect to mailserver error in mail() function

    i try to change following code into the php.ini file
    SMTP = smpt.gmail.com
    smtp_port = 465


    sendmail_from = mddipen@gmail.c om

    when i try to use mail function that time it will give me the following error so give me the proper configuration line to send mail in gmail account.

    i am currently use iis for run php program.
    Following is my code of email.php file:
    Code:
    <?php
    if(mail('mddipen@gmail.com','test subject','test message'))
    	echo('ok');
    else
          echo('not ok');
    ?>

    Following is my error message:
    Warning: mail() [function.mail]: Failed to connect to mailserver at "smpt.gmail.com " port 465, verify your "SMTP" and "smtp_port" setting in php.ini or use ini_set() in E:\revant\New Folder\email.ph p on line 3
    not ok
    Attached Files
    Last edited by Niheel; Jun 18 '11, 09:57 AM.
  • Markus
    Recognized Expert Expert
    • Jun 2007
    • 6092

    #2
    PHP's native mail is only a very basic interface. Instead, take a look at SwiftMailer.

    Comment

    • Dipen Mehta
      New Member
      • Jun 2011
      • 16

      #3
      thank you,
      But i still not send the mail.can you give me code for sending mail(edit my above code)? please send all library files related that code because in swiftmailer library files are missing.

      Comment

      • Niheel
        Recognized Expert Moderator Top Contributor
        • Jul 2005
        • 2432

        #4
        The error you are getting is more likely because in your mail server is set as smpt.gmail.com instead of smtp.gmail.com.

        That could be your problem. Your mail function code looks right the server. So check your php.ini again or where ever you set your mail server settings.
        niheel @ bytes

        Comment

        • Markus
          Recognized Expert Expert
          • Jun 2007
          • 6092

          #5
          I wont write the code for you, no. The link I provided previously shows how to send mail via GMail. PHP's mail facilities aren't able to do this without other libraries because GMail requires TLS and other configurations.

          Comment

          Working...