Home > Backend Development > PHP Tutorial > PHP mailer mail sending_PHP tutorial

PHP mailer mail sending_PHP tutorial

WBOY
Release: 2016-07-13 09:54:59
Original
1237 people have browsed it

PHP mailer email sending

First download the class library phpmailer because smtp.163.php is loaded. Therefore, the sender’s mailbox must use 163 mailbox. Other mailboxes need to be imported from other class libraries. My attachment.xls is the attachment you want to add. It can be any type.

echo "

";
require_once('class.phpmailer.php');


$mail = new PHPMailer(); //Instantiation
$mail->IsSMTP(); // Enable SMTP
$mail->Host = "smtp.163.com"; //SMTP server, taking 163 mailbox as an example
$mail->Port = 25; //Mail sending port
$mail->SMTPAuth = true; //Enable SMTP authentication


$mail->CharSet = "UTF-8"; //Character set
$mail->Encoding = "base64"; //Encoding method


$mail->Username = "yourmail@163.com"; //Your email address 163
$mail->Password = "password"; //Your password
$mail->Subject = "Hello"; //Email title any


$mail->From = "youradmin@163.com"; //Sender address (that is, your email address)
$mail->FromName = "name"; //Sender's name any


$address = "$_POST['email']";//recipient email I sent it via post. This is the recipient's email address
$mail->AddAddress($address, "Dear");//Add recipient (address, nickname)


$mail->AddAttachment('xx.xls','My Attachment.xls'); // Add attachment and specify the name
$mail->IsHTML(true); //Support html format content
$mail->AddEmbeddedImage("logo.jpg", "my-attach", "logo.jpg"); //Set the image in the email
$mail->Body = 'Hello, Friend!
This is an email from PHP mailer mail sending_PHP tutorial.com!
PHP mailer mail sending_PHP tutorial'; //Email body content


//Send
if(!$mail->Send()) {
echo "Failed to send: " . $mail->ErrorInfo;
} else {
echo "Sent successfully!";
}
?>

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/993867.htmlTechArticlePHP mailer Email sending first downloads the class library phpmailer because smtp.163.php is loaded, so the sender’s email address To use 163 mailbox and other mailboxes, you need to introduce other class libraries. My attachment.xls is what you need...
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template