Home > Backend Development > PHP Tutorial > How to send emails using Thinphp_PHP Tutorial

How to send emails using Thinphp_PHP Tutorial

WBOY
Release: 2016-07-13 09:48:20
Original
1247 people have browsed it

How to send email using Thinphp

I haven’t used php for a long time, and suddenly I wanted to use thinkphp to send emails, but the books I checked were very messy, so I didn’t continue reading. I found a better method here:

Step one: First we need to introduce an external class library: Mail.class.php

Put it in the ORG directory (which is the core directory of thinkphp, if you still don’t understand, see the picture below):

How to send emails using Thinphp_PHP Tutorial

In this way, we have introduced the relevant class libraries. The download address of the class library is as follows: Mail.class.php

Step 2:

Add the following configuration information to the common/conf/config.php file (do not copy, the following is your email address):

//Configure email related information
'MAIL_ADDRESS'=>'18753377393@163.com', // Email address
'MAIL_SMTP'=>'smtp.163.com', // Email SMTP server
'MAIL_LOGINNAME'=>'18753377393', // Email login account
'MAIL_PASSWORD'=>'123456789', // Email password
'MAIL_CHARSET'=>'UTF-8',//Encoding
'MAIL_AUTH'=>true,//Email authentication
'MAIL_HTML'=>true,//true HTML format false TXT format

At this time, the configuration of the email function has been completed. The next step is to send:

Step 3: Send email:

Within a specific controller method:

import('.ORG.Mail');//Introducing the mail class
SendMail('Destination address', 'Email title', 'Text', 'Sender'); //The destination address is the email address of the person you want to send it to

After completion, the last step is to check whether the recipient’s mailbox has received the email and whether the format of the email is correct.

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/1023579.htmlTechArticleHow to use Thinphp to send emails. I haven’t touched php for a long time, and suddenly I want to use thinkphp to send emails, but I checked the books and they were all very messy, so I didn’t continue reading. Here I found...
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