Table of Contents
A simple way to send emails with phpmailer (with phpmailer source code download), phpmailer source code download
Home php教程 php手册 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

Jul 06, 2016 pm 02:24 PM
phpmailer send email

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:

<&#63;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;
  }
&#63;>

Copy after login

I hope this article will be helpful to everyone in php programming design.

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

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

PHP methods and steps for sending emails to multiple people using PHPMailer PHP methods and steps for sending emails to multiple people using PHPMailer May 22, 2023 pm 06:10 PM

In web applications, it is often necessary to send emails to multiple recipients at once. PHP is a very popular web development language, and PHPMailer is a common PHP class library for sending emails. PHPMailer provides a rich interface, making sending emails in PHP applications more convenient and easy to use. In this article, we will introduce the methods and steps on how to use PHPMailer to send emails to multiple recipients. To download PHPMailer, you first need to go to the official website (

PHP development practice: Use PHPMailer to send emails to users in the MySQL database PHP development practice: Use PHPMailer to send emails to users in the MySQL database Aug 05, 2023 pm 06:21 PM

PHP development practice: Use PHPMailer to send emails to users in the MySQL database Introduction: In the construction of the modern Internet, email is an important communication tool. Whether it is user registration, password reset, or order confirmation in e-commerce, sending emails is an essential function. This article will introduce how to use PHPMailer to send emails and save the email information to the user information table in the MySQL database. 1. Install the PHPMailer library PHPMailer is

How to send HTML mail with embedded images using PHP and PHPMAILER? How to send HTML mail with embedded images using PHP and PHPMAILER? Jul 22, 2023 am 11:29 AM

How to send HTML mail with embedded images using PHP and PHPMAILER? HTML email is a richer and more personalized form of email that can insert pictures, links and styles into the email. Embedded images refer to sending images directly as part of the email in the HTML email instead of sending them as attachments. In PHP, we can use PHPMAILER to send HTML emails with embedded images. PHPMAILER is a powerful PHP email sending library

PHP and PHPMAILER: How to implement anti-spam function for email sending? PHP and PHPMAILER: How to implement anti-spam function for email sending? Jul 22, 2023 am 11:46 AM

PHP and PHPMAILER: How to implement anti-spam function for email sending? Introduction: In the Internet age, email has become an indispensable part of our daily life and work. However, with the popularity and use of email, the problem of spam has become increasingly serious, causing a lot of trouble to users. In order to solve this problem, this article will introduce how to use PHP and PHPMailer library to implement the anti-spam function of email sending. 1. Understand spam. Spam refers to those unsolicited

How to send email using Flask-Mail How to send email using Flask-Mail Aug 02, 2023 am 10:17 AM

How to use Flask-Mail to send emails With the development of the Internet, email has become an important tool for people to communicate. When developing web applications, sometimes we need to send emails in specific scenarios, such as sending a welcome email after a user successfully registers, or sending a password reset email when a user forgets their password, etc. Flask is a simple and flexible Python Web framework, and Flask-Mail is an extension library for sending emails under the Flask framework. This article will introduce how to

PHP methods and precautions for sending attachment emails using the PHPMailer library PHP methods and precautions for sending attachment emails using the PHPMailer library May 21, 2023 pm 06:12 PM

PHP methods and precautions for sending attachment emails using the PHPMailer library. Email has become a very important way of communication in modern life. In many development projects, we need to use code to automatically send emails. At this time, the PHPMailer library is our best choice. PHPMailer is a library dedicated to sending emails in PHP. It can easily send emails, including HTML-formatted emails and attachments. This article will focus on how to send emails with attachments in the PHPMailer library.

Mastering PHP and PHPMAILER: How to implement the automatic reply function for email sending? Mastering PHP and PHPMAILER: How to implement the automatic reply function for email sending? Jul 22, 2023 am 11:57 AM

Mastering PHP and PHPMAILER: How to implement the automatic reply function for email sending? In modern society, email has become one of the important ways for people to communicate every day. Many websites or companies need to communicate with users through emails, and automatic reply to emails has become very important. This article will introduce how to use PHP and the PHPMailer library to implement the automatic reply function for email sending. Step 1: Get the user’s email information First, we need to get the user’s email information. On a website or application, use

Python connects to Alibaba Cloud interface to implement email sending function Python connects to Alibaba Cloud interface to implement email sending function Jul 05, 2023 pm 04:33 PM

Python connects to the Alibaba Cloud interface to implement the email sending function. Alibaba Cloud provides a series of service interfaces, including email sending services. By connecting to the Alibaba Cloud interface through a Python script, we can quickly send emails. This article will show you how to use Python scripts to connect to the Alibaba Cloud interface and implement the email sending function. First, we need to apply for the email sending service on Alibaba Cloud and obtain the corresponding interface information. In the Alibaba Cloud Management Console, select the email push service and create a new email

See all articles