加入收藏 | 设为首页 | 会员中心 | 我要投稿 济源站长网 (https://www.0391zz.cn/)- 数据工具、数据仓库、行业智能、CDN、运营!
当前位置: 首页 > 教程 > 正文

Linux系统PHP使用sendmail传送邮件

发布时间:2022-06-19 18:13:55 所属栏目:教程 来源:互联网
导读:sendmail是在Unix环境下使用最广泛的实现邮件发送/接受的邮件传输代理程序,下面就教大家如何使用sendmail来配合php发邮件. 安装sendmail和mailx:yum -y install sendmail mailx 启动:/etc/rc.d/init.d/sendmail start 当然也要开机自动启动:vim /etc/rc.loca
  sendmail是在Unix环境下使用最广泛的实现邮件发送/接受的邮件传输代理程序,下面就教大家如何使用sendmail来配合php发邮件.
 
  安装sendmail和mailx:yum -y install sendmail mailx
 
  启动:/etc/rc.d/init.d/sendmail start
 
  当然也要开机自动启动:vim /etc/rc.local
 
  在rc.local后面添加下面代码:
 
  /etc/rc.d/init.d/sendmail start
 
  至此简单的环境就搭建完成了.
 Linux系统PHP使用sendmail传送邮件
  php采用mail()发送邮件 mail(),mail(“接受方email“,”邮件主题”,”正文内容”,”from:发送方email”);代码如下:
 
  <?php
  $from = 'admin@waynerQiu.com';
  $to = '78282385@qq.com';
  $title = '时间你好123!@#¥%……&*()subject';
  $subject = "=?UTF-8?B?".base64_encode($title)."?=";
  $body = '<a href="http://www.phpfensi.com" target="_blank">Test link</a>';
  $headers[] = "From: $from";
  $headers[] = "X-Mailer: PHP";
  $headers[] = "MIME-Version: 1.0";
  $headers[] = "Content-type: text/html; charset=utf8";
  $headers[] = "Reply-To: $from";
  mail($to, $subject, $body, implode("\r\n", $headers), "-f $from");
  ?>。
 

(编辑:济源站长网)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    热点阅读