简体   繁体   中英

Unable to send mail via php mail()

I am unable to send an email via php's mail function.

This is the error I receive. 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 D:\\inetpub\\vhosts\\southernbatteries.com\\httpdocs\\includes\\utils.php on line 6 Array ( [0] => [1] => Could not send mail, please try later... )

What exactly does this mean ? Does it mean there is not mail server installed on my webserver ? Is it possible to use a different mail server. Eg Gmails mail server to send the mail ?

If you want to use built-in mail() , you will need to talk to the server administrator. It is possible to use an external SMTP server on Windows, but it has to be specified in the php.ini settings, and PHP's built-in functions don't support SMTP authentication.

The usual way is to either use a local mail server that in turn can talk to a "real" SMTP server with authentication, or use a mailing package like SwiftMailer that can connect to a 3rd party SMTP server like GMail directly.

You need to have a mail server to send mails. If you only have apache, you cannot, unless you edit the php.ini file and set the smpt_server to one that allows you to do so. Note that this will only work depending on your ISP.

If you have a hosting account you can upload the files and online they will work.

You should run your own mailserver on your server. Most likely it's not started or not installed.

As I can see your are running it on windows it's most likely the later. You could try using your providers mail server. Or googles. But you need most likely a username and password for that.

you should avoid using php's mail()-function as ist connects and disconnects to the mailserver for every mail sent.

instead of that, try to use something like phpMailer wich allows easy configuration and sending a lot of mails without performance-problems.

如果您想运行自己的邮件服务器(例如,如果这是一个开发环境),您可以使用

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM