第一天在簡書寫東西坊罢,就隨便寫點吧………(寫的不是很專業(yè),不要嫌棄………)
-----------------------------我是分割線--------------------------------
在百度上面搜索發(fā)現(xiàn)基本上每個人用的方法都不一樣,一般github的東西會比較好用俏拱,來給你們安利粉怕!項目地址https://github.com/PHPMailer/PHPMailer 復(fù)制這個地址,然后在終端:git clone https://github.com/PHPMailer/PHPMailer 就可以把它下到當(dāng)前目錄
在這個PHPMailer目錄下柳恐,新建一個text.php文件,內(nèi)容:
<?php
require 'PHPMailerAutoload.php';
$mail = new PHPMailer;
//$mail->SMTPDebug = 3; // Enable verbose debug output
$mail->isSMTP(); // ?使用SMTP協(xié)議
$mail->Host = 'smtp.qq.com'; // qq郵箱的服務(wù)器端地址
$mail->SMTPAuth = true; //SMTP 授權(quán)
$mail->Username = '要發(fā)送端郵箱@qq.com'; // 配置發(fā)送郵箱的用戶
$mail->Password = '?mima'; // 配置發(fā)送端郵箱密碼
$mail->SMTPSecure = 'ssl'; // Enable TLS encryption, `ssl` also accepted
$mail->Port = 465; //qq郵箱的ssl的端口是465
$mail->setFrom('發(fā)送端郵箱@qq.com', 'Mailer'); //發(fā)送地址热幔,昵稱
$mail->addAddress('接收郵箱@qq.com', 'Joe User'); // 接收地址乐设,昵稱
// $mail->addAddress('ellen@example.com'); // Name is optional
// $mail->addReplyTo('info@example.com', 'Information');
// $mail->addCC('cc@example.com');
// $mail->addBCC('bcc@example.com');
// $mail->addAttachment('/var/tmp/file.tar.gz'); // Add attachments
// $mail->addAttachment('/tmp/image.jpg', 'new.jpg'); // Optional name
$mail->isHTML(true); // Set email format to HTML
// 主題
$mail->Subject = 'Here is the subject';$mail->Body = 'This is the HTML message body**in bold!**';
$mail->AltBody = 'This is the body in plain text for non-HTML mail clients';//內(nèi)容
if(!$mail->send()) {
echo 'Message could not be sent.';
echo 'Mailer Error: ' . $mail->ErrorInfo;}
else {
echo 'Message has been sent';
}
?>
-----------------------分割線---------------------