Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
819 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 Answer

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...