Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
773 views
in Technique[技术] by (71.8m points)

php - Warning: mail() [function.mail]: Failed to connect to mailserver

Getting error message

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

Ive opened up php.ini and i believe i need to add

SMTP "localhost" PHP_INI_ALL
smtp_port "25" PHP_INI_ALL
sendmail_from NULL PHP_INI_ALL
sendmail_path NULL PHP_INI_SYSTEM

Im not sure where to add it though? Also correct me if anything i believe i need to do is incorrect. Im currently developing website on localhost so if anything i need to please tell me.

EDIT**

My local host is XAMPP amd i believe this has a mail server

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

You're probably not running an SMTP server on your localhost.

If you only need an SMTP server for development purposes, and you're running Windows, install smtp4dev, which can be found here: http://smtp4dev.codeplex.com/

It's a beautiful little piece of software that sits in your task bar and lets you see all email that is being sent to it. It doesn't actually send email anywhere, so you can work with live data without fear of spamming someone.

Then, when you want your application to actually send email (when you run it on the server), you will need an SMTP server address instead of "localhost". If you don't know which SMTP to use, speak to your network administrator or ISP.

Last but not least, if you access your email through an email program, you can probably find the "Outgoing server" in your settings somewhere, although that depends on which mail program you use. An "SMTP server" and an "Outgoing server" are exactly the same thing.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...