php 发邮件 500错误,使用PHP发送邮件出现这个错误:The following From address failed:xxxx@163.com...
使用了TP框架!以下是源碼:
namespace ApiController;
use ThinkController;
class EmailController extends Controller
{
public function test(){
$msg = pmail('493107977@qq.com','午夜DJ','封裝測(cè)試','hello world');
echo $msg;
}
?php>
return array(
//'配置項(xiàng)'=>'配置值'
'TMPL_PARSE_STRING' => array(
'__ADMIN__' => '/Public/Admin',
'__COMMON__' => '/Public/Common',
'__VENDORS__' => '/Public/Venders',
'__HOME__' => '/Public/Home',
'__USER__' => '/Public/User',
'__UP_GOODS__'=>'/Public/Uploads/Goods',
'__UP_USER__'=>'/Public/Uploads/User'
),
'PMAIL' => array(
'Host' => 'stmp.163.com',
'Username' => 'xxxxxx',
'Password' => 'xxxxxx',
'From' => 'xxxxx@163.com',
'FromName' => 'xxxx',
),
);
function pmail($tomail = ”,$toname = ”,$title = ”,$content = ”){
require_once VENDOR_PATH.'PHPMailer/class.phpmailer.php';
// 實(shí)例化
$pm = new \PHPMailer();
foreach (C('PMAIL') as $k => $v){
$pm->$k = $v;
}
// 服務(wù)器相關(guān)信息
// $pm->Host = ‘smtp.163.com’; // SMTP服務(wù)器
$pm->IsSMTP(); // 設(shè)置使用SMTP服務(wù)器發(fā)送郵件
$pm->SMTPAuth = true; // 需要SMTP身份認(rèn)證
// $pm->Username = ‘woainigui8888’; // 登錄SMTP服務(wù)器的用戶名
// $pm->Password = ‘7618387asd’; // 登錄SMTP服務(wù)器的密碼
//
發(fā)件人信息
// $pm->From = ‘woainigui8888@163.com’;
// $pm->FromName = ‘電音之王’;
// 收件人信息
$pm->AddAddress($tomail,$toname); // 添加一個(gè)收件人
// 郵件內(nèi)容
$pm->CharSet = 'utf-8'; // 內(nèi)容編碼
$pm->Subject = $title; // 郵件標(biāo)題
$pm->MsgHTML($content); // 郵件內(nèi)容
// $this->AddAttachment($path); // 附件
// 發(fā)送郵件
if($pm->Send()){
return true;
}else {
return $pm->ErrorInfo;
}
}
使用PHP發(fā)送郵件出現(xiàn)這個(gè)錯(cuò)誤:The following From address failed:xxxx@163.com
創(chuàng)作挑戰(zhàn)賽新人創(chuàng)作獎(jiǎng)勵(lì)來(lái)咯,堅(jiān)持創(chuàng)作打卡瓜分現(xiàn)金大獎(jiǎng)總結(jié)
以上是生活随笔為你收集整理的php 发邮件 500错误,使用PHP发送邮件出现这个错误:The following From address failed:xxxx@163.com...的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: 绝地求生闪镜怎么设置
- 下一篇: php里面电话验证码,PHP的中问验证码