douhuan7862 2013-12-10 14:56
浏览 64
已采纳

sendmail返回错误代码8

Simple PHP script running on BlueHost where mail is handled by Google Apps:

<?php
  require_once('Mail.php');
  $subject = 'Test Subject';
  $message = 'Test Message';

  $to = 'to@example.com'; // address on this domain
  $from = 'from@example.com'; // another address on the domain
  $fromname = 'John Doe';

  $headers = array(
    'Return-Path' => $from,
    'From' => $from,
    'X-Priority' => '3',
    'X-Mailer' => 'PHP ' . phpversion(),
    'Reply-To' =>  "$fromname <$from>",
    'MIME-Version' => '1.0',
    'Content-Transfer-Encoding' => '8bit',
    'Content-Type' => 'text/plain; charset=UTF-8',
    'To' => $to,
    'Subject' => $subject
  );

  $params = '-i -v -f ' . $from;
  $sendmail = Mail::factory('sendmail', $params);
  $mail = $sendmail->send($to, $headers, $message);

  if (PEAR::isError($mail)) { $status = $mail->getMessage(); }
?>

$status is being set to sendmail returned error code 8.

  • 写回答

1条回答 默认 最新

  • douyan2970 2013-12-10 14:56
    关注

    Looks like I needed to do two things:

    1. BlueHost checks that the From: address is in cPanel--even if Google Apps handles the mail. Apparently cPanel updates the trusted users list for sendmail.

    2. If the To: address is on the same host, it also has to exist in cPanel, although I'm not sure why (sendmail optimization?).

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 Windows Script Host 无法找到脚本文件"C:\ProgramData\Player800\Cotrl.vbs”
  • ¥15 matlab自定义损失函数
  • ¥15 35114 SVAC视频验签的问题
  • ¥15 impedancepy
  • ¥15 求往届大挑得奖作品(ppt…)
  • ¥15 如何在vue.config.js中读取到public文件夹下window.APP_CONFIG.API_BASE_URL的值
  • ¥50 浦育平台scratch图形化编程
  • ¥20 求这个的原理图 只要原理图
  • ¥15 vue2项目中,如何配置环境,可以在打完包之后修改请求的服务器地址
  • ¥20 微信的店铺小程序如何修改背景图