我又来了关于邮件发送问题
我又来了
有什么问题

回复#5 @lincanbin :
› 密保邮件发送失败Mailer Error: The following From address failed: cforum : MAIL FROM command failed,Command parsing failed ,501,SMTP server error: MAIL FROM command failed Detail: Command parsing failed SMTP code: 501SMTP server error: MAIL FROM command failed Detail: Command parsing failed SMTP code: 501
回复#11 @lincanbin :
官方给的api是这样的
<?php
set_include_path("/usr/local/lib/php/");
include_once 'Mail.php';
include_once 'Mail/smtp.php';
# 发信人,用正确邮件地址替代
$from='testaddress@qq.com';
# 收件人地址,用正确邮件地址替代
$to = array('test1@qq.com','test2@163.com');
# 邮件标题
$subject='SendCloud PHP Smtp Example';
# 邮件正文,html格式
$body = "<html><head></head><body>
欢迎使用<a href='http://sendcloud.sohu.com'>SendCloud!
</body></html>";
# smtp参数, 用正确api_user和api_key验证
$param = array (
'host'=>'smtp.sendcloud.net',
'ip'=>25,
'auth'=>true,
'username'=>'api_user',
'password'=>'api_key');
$headers = array (
'From' => $from,
'To' => $to,
'Subject' => $subject,
'Content-Type' => 'text/html;charset=utf8');
function getMessageId($res)
{
$list = explode('#',$res);
return $list[1];
}
$mail = new Mail_smtp($param);
$res = $mail->send($to, $headers, $body);
$messageId = getMessageId($res);
echo $messageId;示例2
<?php
set_include_path("/usr/local/lib/php/");
require_once "Mail.php";
# 发信人,用正确邮件地址替代
$from = "sendcloud@sendcloud.org";
# 收件人地址,用正确邮件地址替代
$to = "to@sendcloud.org";
$subject = "SendCloud PHP Smtp Example";
# 邮件正文,html格式
$body = "<html><head></head><body>
欢迎使用<a href='http://sendcloud.sohu.com'>SendCloud!
</body></html>";
# 使用api_user和api_key进行验证
$username = "api_user";
$password = "api_key";
$host = "smtp.sendcloud.net";
$port = 25;
$headers = array (
'From' => $from,
'To' => $to,
'Subject' => $subject,
'Content-Type' => 'text/html;charset=utf8');
$smtp = Mail::factory(
'smtp',
array (
'host' => $host,
'port' => $port,
'auth' => true,
'debug' => true,
'username' => $username,
'password' => $password));
$mail = $smtp->send($to, $headers, $body);
if (PEAR::isError($mail)) {
echo("" . $mail->getMessage() . "
");
}
else {
echo("Successfully!
");
}
?>登录后方可回帖

粤公网安备 44030602003677号
@lincanbin