这个例子说明如何发送电子邮件使用SMTP身份验证。此特定示例使用Gmail发送。为通过SMTP发送如需Gmail要求的SMTP TLS身份验证。幸运的是,当我们使用梨邮件认证,连接自动TLS的。
这个例子之间的区别,只是在前面的示例使用SMTP是增加以下SMTP参数。
$smtp_params["auth"] = true; $smtp_params["username"] = "[email protected]"; $smtp_params["password"] = "pass";
include('Mail.php');
include('Mail/mime.php');
// Constructing the email
$sender = "[email protected]"; // Your email address
$recipient = "Leigh.net>"; // The Recipients name and email address
$subject = "Test Email"; // Subject for the email
$text = 'This is a text message.'; // Text version of the email
$html = 'This is a html message
'; // HTML version of the email
$crlf = "n";
$headers = array(
'From' => $sender,
'Return-Path' => $sender,
'Subject' => $subject
);
// Creating the Mime message
$mime = new Mail_mime($crlf);
// Setting the body of the email
$mime->setTXTBody($text);
$mime->setHTMLBody($html);
// Add an attachment
$file = "Hello World!";
$file_name = "Hello text.txt";
$content_type = "text/plain";
$mime->addAttachment ($file, $content_type, $file_name, 0);
// Set body and headers ready for base mail class
$body = $mime->get();
$headers = $mime->headers($headers);
// SMTP authentication params
$smtp_params["host"] = "smtp.gmail.com";
$smtp_params["port"] = "25";
$smtp_params["auth"] = true;
$smtp_params["username"] = "[email protected]";
$smtp_params["password"] = "pass";
// Sending the email using smtp
$mail =& Mail::factory("smtp", $smtp_params);
$result = $mail->send($recipient, $headers, $body);
if($result === 1)
{
echo("Your message has been sent!");
}
else
{
echo("Your message was not sent: " . $result);
}
?>
荒野乱斗国际版 (BrawlStars)最新版本v56.274
下载一波超人内置修改器菜单版 安卓版v1.0.2
下载敢达决战官方正版 安卓版v6.7.9
下载敢达决战 安卓版v6.7.9
下载继承了一座戏园子无限声望铜钱版 内置菜单最新版v1.7
继承了一座戏园子折相思版是游戏的破解版本,在该版本中为玩家提
山河半世橙光清软金手指版 无限鲜花v3.24
山河半世是一款超级好玩的橙光恋爱游戏,在游戏中玩家们需要扮演
蓬莱手游折相思版 安卓版v1.0.0
蓬莱免广告版是游戏的修改版本,在该版本中为玩家去除了广告,玩
当红影后橙光游戏破解版2025 最新版v1.0
当红影后橙光破解版是一款超级好玩的娱乐圈题材的橙光游戏,在这
忽然成了万人迷清软完结版 无限鲜花版v12.15
忽然成了万人迷破解版是一款非常好玩的男性向橙光游戏,在有一天