doutui4649 2014-02-05 15:43
浏览 127
已采纳

从localhost发送电子邮件?

im kinda stuck, i have read some threads where they use google smtp to send mails from localhost. Im using xampp right now and im trying to use google smtp but it doesn't work what have i done wrong ?

Warning: 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:\page.php on line 48

My Code in php.ini:

sendmail_from = T***@gmail.com
Gmail SMTP server address: smtp.gmail.com
Gmail SMTP user name: T***@gmail.com
Gmail SMTP password: ****
Gmail SMTP port: 465
Gmail SMTP TLS/SSL required: yes
  • 写回答

1条回答 默认 最新

  • donglei7152 2014-02-05 15:54
    关注

    You have to set the SMTP-Server, Port and authentication credentials in your php.ini.

    But for this it's much easier to use the wonderful PHPMailer class.

    It's very easy to implement and to use.

    You can easily send complex emails (HTML, Attachments) and it has a good support for external SMTP server, including e.g. encryption.

    Just take a look at the examples in the "examples" folder or scroll down at the linked page where is an example using SMTP auth in the first code-block.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?