手机版
你好,游客 登录 注册 搜索
背景:
阅读新闻

Ubuntu Server 安装Sendmail

[日期:2012-07-12] 来源:Linux社区  作者:mymbk [字体:大 中 小]

打开终端,输入命令:
sudo apt-get install sendmail
安装完
ps aux |grep sendmail

输出如下:
root      9391 0.0 0.3   8748 2000 ?        Ss   00:14   0:00 sendmail: MTA: accepting connections         
andy     13332 0.0 0.1   3236   792 pts/0    R+   03:58   0:00 grep sendmail

证明sendmail已经成功启动了

sudo vi /etc/php5/apache2/php.ini
找到 sendmail_path,修改为:
sendmail_path = /usr/sbin/sendmail -i -t

重启apache
sudo apache2ctl restart

测试

常用发送邮件方式如下:

    1.如何写一般的邮件: mail linux@www.linuxidc.com 编辑抄送对象,邮件主题,邮件正文后,按Ctrl-D结束

    2.快速发送方式: echo “邮件正文” | mail -s 邮件主题 linux@www.linuxidc.com

    3.以文件内容作为邮件正文来发送: mail -s test linux@www.linuxidc.com < test.txt

    4.发送带附件的邮件: uuencode 附件名称 附件显示名称 | mail -s 邮件主题 发送地址

       例如: uuencode test.txt test.txt | mail -s Test linux@www.linuxidc.com

<?php
$now = date("Y-m-d h:i:s");
$from_name = "yourname";
$from_email = "yourqq@qq.com";
$headers = "From: $from_name <$from_email>";
$body = "嗨,这是一封测试信件来自".$from_name."<".$from_email.">";
$subject = "[".$now."] 测试信件发送";


if (mail($from_email, $subject, $body, $headers)) {
echo "success!";
} else {
echo "fail";
}
?>

linux
相关资讯       Ubuntu Server 
本文评论   查看全部评论 (0)
表情: 表情 姓名: 字数

       

评论声明
  • 尊重网上道德,遵守中华人民共和国的各项有关法律法规
  • 承担一切因您的行为而直接或间接导致的民事或刑事法律责任
  • 本站管理人员有权保留或删除其管辖留言中的任意内容
  • 本站有权在网站内转载或引用您的评论
  • 参与本评论即表明您已经阅读并接受上述条款