最近计划重新整改站点,一直有个问题困扰,那就是网站无法发送邮件,这样新用户就无法注册,自己也无法找回密码。

安装了WP email SMTP插件,虽然测试邮件可以发送成功。但注册时也无法发送邮件。

下面我为大家介绍解决办法:

1.首先测试自己的服务器或主机是否支持mail函数。测试代码如下:

<?php if (function_exists('mail')) { echo "支持mail()函数!"; } else echo "不支持mail()函数!"; ?>

2.如果测试为支持,但仍然无法发送邮件,请打开php.ini修改如下配置:

[mail function]

; For Win32 only.

; http://php.net/smtp

SMTP = localhost

; http://php.net/smtp-port

smtp_port = 25

; For Win32 only.

; http://php.net/sendmail-from

sendmail_from = x.x.x.x@yy.com (此项为你发送的邮箱)

; For Unix only. You may supply arguments as well (default: "sendmail -t -i").

; http://php.net/sendmail-path

sendmail_path ="c:/sendmail/sendmail.exe -t -i"

sendmail见如下分享:

http://pan.baidu.com/s/1c2FrcC4

将此文件上传到服务器。

然后打开sendmail.ini.进行如下配置:

[sendmail]

; you must change mail.mydomain.com to your smtp server

smtp_server=smtp.163.com (此项为自己的邮件SMTP地址)

smtp_port=25

smtp_ssl=auto

; the default domain for this server will be read from the registry

; this will be appended to email addresses when one isn't provided

; if you want to override the value in the registry, uncomment and modify

;default_domain=mydomain.com

; log smtp errors to error.log (defaults to same directory as sendmail.exe)

; uncomment to enable logging

error_logfile=error.log

; create debug log as debug.log (defaults to same directory as sendmail.exe)

; uncomment to enable debugging

debug_logfile=debug.log

; if your smtp server requires authentication, modify the following two lines

auth_username=X.X.X.@163.com (邮件用户名)

auth_password=* (邮件密码)

; if your smtp server uses pop3 before smtp authentication, modify the

; following three lines

;pop3_server=

;pop3_username=

;pop3_password=

; to force the sender to always be the following email address, uncomment and

; populate with a valid email address. this will only affect the "MAIL FROM"

; command, it won't modify the "From: " header of the message content

force_sender=X.X.X.X@163.com (邮件地址)

; sendmail will use your hostname and your default_domain in the ehlo/helo

; smtp greeting. you can manually set the ehlo/helo name if required

;hostname=

配置完上述文件后,重启网站应该即可解决。

注意有的主题可能不支持邮件的发送,建议更换。