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
 
  至此简单的环境就搭建完成了.
 
  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");
  ?>。
 

dawei

【声明】:站长网内容转载自互联网,其相关言论仅代表作者个人观点绝非权威,不代表本站立场。如您发现内容存在版权问题,请提交相关链接至邮箱:bqsm@foxmail.com,我们将及时予以处理。