Use the TP frame! The following is the source code:
namespace Apicontroller;
Use Thinkcontroller;
Class Emailcontroller extends Controller
{
Public Function test () {
$msg = pmail('493107977@qq.com','午夜DJ','封装测试','hello world'); echo $msg;
}
?php>
Return Array (
//'配置项'=>'配置值''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';// 实例化$pm = new \PHPMailer();foreach (C('PMAIL') as $k => $v){ $pm->$k = $v;}
Server-related information
$pm->host = ' smtp.163.com '; SMTP server
$pm->IsSMTP(); // 设置使用SMTP服务器发送邮件$pm->SMTPAuth = true; // 需要SMTP身份认证
$pm->username = ' woainigui8888 '; User name to log on to the SMTP server
$pm->password = ' 7618387asd '; Password to log on to the SMTP server
//
Sender Information
$pm->from = ' woainigui8888@163.com ';
$PM->fromname = ' The King of electrical tones ';
Recipient information
$pm->AddAddress($tomail,$toname); // 添加一个收件人
Message content
$pm->CharSet = 'utf-8'; // 内容编码$pm->Subject = $title; // 邮件标题$pm->MsgHTML($content); // 邮件内容
$this->addattachment ($path); Attachment
Send mail
if($pm->Send()){ return true;}else { return $pm->ErrorInfo;}
}
This error occurs when sending a message using PHP: The following from address failed:xxxx@163.com
Reply content:
Use the TP frame! The following is the source code:
namespace Apicontroller;
Use Thinkcontroller;
Class Emailcontroller extends Controller
{
Public Function test () {
$msg = pmail('493107977@qq.com','午夜DJ','封装测试','hello world'); echo $msg;
}
?php>
Return Array (
//'配置项'=>'配置值''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';// 实例化$pm = new \PHPMailer();foreach (C('PMAIL') as $k => $v){ $pm->$k = $v;}
Server-related information
$pm->host = ' smtp.163.com '; SMTP server
$pm->IsSMTP(); // 设置使用SMTP服务器发送邮件$pm->SMTPAuth = true; // 需要SMTP身份认证
$pm->username = ' woainigui8888 '; User name to log on to the SMTP server
$pm->password = ' 7618387asd '; Password to log on to the SMTP server
//
Sender Information
$pm->from = ' woainigui8888@163.com ';
$PM->fromname = ' The King of electrical tones ';
Recipient information
$pm->AddAddress($tomail,$toname); // 添加一个收件人
Message content
$pm->CharSet = 'utf-8'; // 内容编码$pm->Subject = $title; // 邮件标题$pm->MsgHTML($content); // 邮件内容
$this->addattachment ($path); Attachment
Send mail
if($pm->Send()){ return true;}else { return $pm->ErrorInfo;}
}
This error occurs when sending a message using PHP: The following from address failed:xxxx@163.com