在太阳下
不管你喜不喜欢,高不高兴,爱与不爱;太阳照旧照耀着你!温暖着你!

WordPress 不能发邮件

WordPress 不能发邮件
服务器环境Linux CentOS 7-x86_64-bbr
首先来检测一下网站服务器是否支持邮件发送
创建一个PHP文件,上传到网站根目录

[php]
<?php
$txt = “hello”;
// 以下的邮箱地址改成你的
$mail = ‘somebody@example.com’;
// 发送邮件
mail($mail, “My subject”, $txt);
echo ‘message was sent!’;
?>
[/php]

把该文件,上传到网站根目录,并且访问该文件
如果在邮箱收到该测试邮件,说明该服务器是支持mail()函数的
如果没收到,则需要摆弄一下
据说邮箱收不到邮件是因为mail函数发送邮件失败了。php中mail函数是一个自带的发邮件的函数,但是如果你真的要使用mail函数来发邮件那必须是要给你系统安装sendmail组件才可以。
先使用以下命令检查是否已安装sendmail:
rpm –q sendmail

[sourcecode language=”plain”]
[root@host ~]# rpm –q sendmail
RPM version 4.8.0
Copyright (C) 1998-2002 – Red Hat, Inc.
This program may be freely redistributed under the terms of the GNU GPL

Usage: rpm [-aKfgpWHqVcdilsKiv?] [-a|–all] [-f|–file] [-g|–group] [-p|–package] [-W|–ftswalk]
[–pkgid] [–hdrid] [–fileid] [–specfile] [–triggeredby] [–whatrequires]
[–whatprovides] [–nomanifest] [-c|–configfiles] [-d|–docfiles] [–dump] [-l|–list]
[–queryformat=QUERYFORMAT] [-s|–state] [–nofiledigest] [–nomd5] [–nofiles]
[–nodeps] [–noscript] [–comfollow] [–logical] [–nochdir] [–nostat] [–physical]
[–seedot] [–xdev] [–whiteout] [–addsign] [-K|–checksig] [–delsign] [–import]
[–resign] [–nodigest] [–nosignature] [–initdb] [–rebuilddb] [–aid] [–allfiles]
[–allmatches] [–badreloc] [-e|–erase &amp;lt;package&amp;gt;+] [–excludedocs] [–excludepath=&amp;lt;path&amp;gt;]
[–fileconflicts] [–force] [-F|–freshen &amp;lt;packagefile&amp;gt;+] [-h|–hash] [–ignorearch]
[–ignoreos] [–ignoresize] [-i|–install] [–justdb] [–nodeps] [–nofiledigest]
[–nomd5] [–nocontexts] [–noorder] [–nosuggest] [–noscripts] [–notriggers]
[–oldpackage] [–percent] [–prefix=&amp;lt;dir&amp;gt;] [–relocate=&amp;lt;old&amp;gt;=&amp;lt;new&amp;gt;] [–replacefiles]
[–replacepkgs] [–test] [-U|–upgrade &amp;lt;packagefile&amp;gt;+] [–quiet] [-D|–define ‘MACRO EXPR’]
[-E|–eval ‘EXPR’] [–macros=&amp;lt;FILE:…&amp;gt;] [–nodigest] [–nosignature]
[–rcfile=&amp;lt;FILE:…&amp;gt;] [-r|–root ROOT] [–querytags] [–showrc] [–quiet] [-v|–verbose]
[–version] [-?|–help] [–usage] [–scripts] [–setperms] [–setugids] [–conflicts]
[–obsoletes] [–provides] [–requires] [–info] [–changelog] [–xml] [–triggers]
[–last] [–dupes] [–filesbypkg] [–fileclass] [–filecolor] [–fscontext]
[–fileprovide] [–filerequire] [–filecaps]
[/sourcecode]

这里显示已经安装了4.8.0的版本
检测sendmail是否运行正常
/etc/init.d/sendmail status

[sourcecode language=”plain”]
[root@host ~]# /etc/init.d/sendmail status
sendmail is stopped
sm-client is stopped
[/sourcecode]

返回的结果是没有运行
没有运行,那么我们启动sendmail
/etc/init.d/sendmail start

[sourcecode language=”plain”]
[root@host ~]# /etc/init.d/sendmail start
Starting sendmail: [ OK ]
Starting sm-client: [ OK ]
[/sourcecode]

哇塞,简直不敢相信,当我敲下回车键,我的手机响个不停,拾起手机,全是WordPress程序发过来的邮件,开心
2018年11月8日09:50:55
参考教材
https://www.weisay.com/blog/lnmp-mail-sendmail.html
https://blog.csdn.net/XIAOWEI_JIN/article/details/50544699

评论 抢沙发

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址