


A simple way to send emails with phpmailer (with phpmailer source code download), phpmailer source code download
A simple way to send emails with phpmailer (with phpmailer source code download), phpmailer source code download
The example in this article describes a simple way to send emails with phpmailer. Share it with everyone for your reference, the details are as follows:
First of all, click hereDownload the corresponding php file from this site.
After decompression, there are 2 php files (2 classes) and 1 html file (API)
Put the 2 php files into the php project
Brief description: I am using an email address of 163 to send a message to an email address of 126
The key code is as follows:
<?php require 'class.phpmailer.php'; $mail = new PHPMailer(true); //建立邮件发送类 $mail->CharSet = "UTF-8";//设置信息的编码类型 $address = "******@126.com";//收件人地址 $mail->IsSMTP(); // 使用SMTP方式发送 $mail->Host = "smtp.163.com"; //使用163邮箱服务器 $mail->SMTPAuth = true; // 启用SMTP验证功能 $mail->Username = "******@163.com"; //你的163服务器邮箱账号 $mail->Password = "******"; // 163邮箱密码 $mail->Port = 25;//邮箱服务器端口号 $mail->From = "******@163.com"; //邮件发送者email地址 $mail->FromName = "测试邮件";//发件人名称 $mail->AddAddress("$address", "张三"); //收件人地址,可以替换成任何想要接收邮件的email信箱,格式是AddAddress("收件人email","收件人姓名") $mail->AddAttachment("D:\abc.txt"); // 添加附件(注意:路径不能有中文) $mail->IsHTML(true);//是否使用HTML格式 $mail->Subject = "测试测试"; //邮件标题 $mail->Body = "新年快乐"; //邮件内容,上面设置HTML,则可以是HTML if (!$mail->Send()) { echo "邮件发送失败. <p>"; echo "错误原因: " . $mail->ErrorInfo; exit; } ?>
I hope this article will be helpful to everyone in php programming design.

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

SublimeText3 Chinese version
Chinese version, very easy to use

MantisBT
Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

PhpStorm Mac version
The latest (2018.2.1) professional PHP integrated development tool

WebStorm Mac version
Useful JavaScript development tools

ZendStudio 13.5.1 Mac
Powerful PHP integrated development environment