参看http://www.absolutelytech.com/2010/07/18/howto-send-emailsusing-mail-function-from-localhost-in-php-through-msmtp-using-gmail-account-on-linux/ 的步骤:
Step by step instructions:
- First of all, follow this tutorial:
Install msmtp on your linux box and configure it to work with Gmail.
Msmtp is highly configurable and you can easily configure it to work with any smtp server. If you wish to use any other service with msmtp, you may read its manual and configure it.
Proceed to next step only if you have successfully configured and are able to send a test message.
- Open php.ini in your text editor.
sudo gedit /etc/php5/apache2/php.ini
Search for ‘sendmail_path’ and change it to look like
sendmail_path = '/usr/bin/msmtp -t'
Save the file and exit the text editor.
Please note that your msmtp path may vary if you are not using Ubuntu. You may find the path to executable by:
- Restart apache:
sudo /etc/init.d/apache2 restart
OR
sudo /opt/lampp/lampp restart
-
Everything’s done. Lets test if the mail() function is working now:
if ( mail ( 'yourusername@gmail.com', 'Test mail from localhost', 'Working Fine.' ) );
echo 'Mail sent';
else
echo 'Error. Please check error log.';
Replace the yourusername@gmail.com with your own username, save it into a php file along with php delimeters in your virtual host root folder and execute it through the browser. You should receive a mail.
跟上述步骤大同小异。
msmtp在ubuntu下apt-get install msmtp就可以安装, 安装完后, msmtp --ver 查看:
......
System configuration file name: /etc/msmtprc
User configuration file name: /root/.msmtprc
显然要保证有/etc/msmtprc文件并要设置好它的配置内容。我的/etc/msmtprc内容如下:
# Set default values for all following accounts.
defaults
logfile /usr/local/msmtp/msmtp.log
# The SMTP server of the provider.
account test
# SMTP邮件服务器地址
host smtp.ym.163.com
# 发送的邮件Email
from yanghf@kopere.com
auth login
# 邮件服务器登录账号
user yanghf@xxx.com
# 邮件服务器登陆密码
password 12345678
# Set a default account
account default : test
不过,我打开上面的测试php时,开始时出来Error. Please check error log.
发送邮件不成功,查看apache的error_log, 找到错误信息:
msmtp: /etc/msmtprc: must be owned by you
原来是/etc/msmtprc的权限是777的话也不行,需要限制。 ps aux|grep httpd查看apache的进程的用户名是www,
然后:
chown www.www /etc/msmtprc
chmod 600 /etc/msmtprc # 一定要600而不是777 !
搞定!
然后在mantis里配置 $g_phpMailer_method = PHPMAILER_METHOD_MAIL
这样比配置 PHPMAILER_METHOD_SMTP 发邮件要快得多,都可立即收到邮件!
分享到:
相关推荐
tar xvf msmtp-1.4.17.tar.bz2 cd msmtp-1.4.17 ./configure --prefix=/usr/local/msmtp make make install cd /usr/local/msmtp/ mkdir etc #配置文件目录和配置文件都要自己建 cd etc vim msmtprc #手动创建配置...
centos+mutt+msmtp一键部署邮件发送,部署时需要将脚本中相关地方更改为自己的。
执行install.sh前需下载依赖 yum -y install ncurses-devel gcc gcc-c++ gnutls gnutls-devel gnutls-utils openssl openssl-devel libidn libidn-devel
MSMTP用于邮件客户端软件,用于监控系统和应用发送短信或者邮件给到运维工作人员
主要为大家详细介绍了centos配置mutt和msmtp实现邮件发送,具有一定的参考价值,感兴趣的小伙伴们可以参考一下
msmtp+mutt可以搞定服务器发邮件
CentOS发送邮件 mutt+msmtp 模式发送邮件 是个不错的选择
msmtp mail扩展 mailx sendmail
CentOS发送邮件 mutt+msmtp 模式发送邮件 是个不错的选择。
msmtp-1.4.32.tar.bz2,msmtp邮件服务
简单的脚本,用于管理在离线状态下使用msmtp发送的电子邮件。 它是根据msmtp附带的msmtpq脚本集建模的,并添加了一些增强功能: 它解析msmtprc文件,并尝试找出用于网络检查的主机和端口。 这样,当通过VPN连接到...
主要介绍了Linux部署msmtp+mutt实现发送邮件,msmtp是一个SMTP客户端,可将邮件发送至SMTP服务端。具体安装步骤大家参考下本
mutt+msmtp 安装文件和完整配置文档
msmtp源程序实现了嵌入式消息的发送,并结合mutt壳能量实现了电子邮件的发送和接收.zip
脚本监控服务器磁盘使用率,并自动 发送邮件通知,显示每天服务期磁盘使用率信息,也可更改脚本,只发送告警信息。这个随意~
似乎不再维护sSMTP,建议使用MSMTP替代。 这篇文章讨论了如何进行更换。
而msmtprc是发送邮件软件的配置文件,放在/etc下面就可以,也就是说我们还需要一个邮件发送器,我这里面没有,需要单独下载,各位可以google msmtprc;而EmailCall.sh和jasmine-repository-server.log是我对多个git...
msmtp设置 在Debian , CentOS , Ubuntu , Alpine和Archlinux上安装和配置角色。 要求 没有任何 角色变量 钥匙 价值 msmtp_global_tls_trustfile ca证书的位置 msmtp_global_auth 对所有帐户启用身份验证 msmtp_...
此项目建立在msmtp(命令行仅发送电子邮件客户端)所包含的脚本的基础上(并添加了其他脚本),以使其充当排队的邮件传输代理(通过充当sendmail命令;它还提供了一个极简的SMTP服务器模式)和一些其他功能,例如...
主要介绍了树莓派 msmtp和mutt 的安装和配置教程,本文给大家介绍的非常详细,具有一定的参考借鉴价值,需要的朋友可以参考下