duangewu5234 2013-05-13 07:30
浏览 65

PHP和SMTP服务器

My simple code below:

$headers = 'MIME-Version: 1.0' . "
";
$headers .= 'Content-type: text/html; charset=UTF-8' . "
";
$headers .= "From: info@mail.com 
";
$headers .= 'Bcc: test@mail.com' . "
";

$subject = "Information";

if (mail($email, $subject, $message, $headers)) {
    $mail_status = "success";
} else {
    $mail_status = "fail";
}

if ($mail_status == "success") echo '{"status":"success"}';

How can I support SMTP support?

  • 写回答

2条回答 默认 最新

  • douguabu8960 2013-05-13 07:32
    关注

    SMTP server has to be configured on server, but by PHP, which is a programming language. Ask Server admin to provide you SMTP details.

    SMTP information can be set in php.ini or via ini_set()

    Example:

    ini_set("SMTP","smtp.example.com" );
    ini_set('sendmail_from', 'user@example.com'); 
    

    By the way, if you require SMTP Authentication, mail() does not support it. Try to use other PHP mail library such as SwiftMailer or PHPMailer.

    评论

报告相同问题?

悬赏问题

  • ¥100 为什么这个恒流源电路不能恒流?
  • ¥15 有偿求跨组件数据流路径图
  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
  • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 CSAPPattacklab
  • ¥15 一直显示正在等待HID—ISP
  • ¥15 Python turtle 画图
  • ¥15 关于大棚监测的pcb板设计
  • ¥15 stm32开发clion时遇到的编译问题
  • ¥15 lna设计 源简并电感型共源放大器