This article mainly introduces PHP email sending cases. Interested friends can refer to it. I hope it will be helpful to everyone.
The role of the mail() function: Connect to the mail server, use the smtp protocol, interact with the server and send mail.
Note:
1. The mail function does not support the esmtp protocol, that is, it can only cast directly and cannot log in.
2. From the above article, we can only send directly to the final receiving server address. And this address is specified in PHP.ini, so we want to use the mail() function to aseoev@ If 163.com sends an email, we need to ---
1) Query the address of the 163 mail server
2) Write the address to php. ini to
php example code is as follows:
SMTP = 163mx02.mxmail.netease.com sendmail_from = wusong@192.168.1.100 var_dump(mail('12345678@qq.com','from php mail function','very intresting'));
But to use the mail function that comes with php to send emails, we need to install one in linux Only sendmail component can be used, otherwise it cannot be used.
If you don’t have this sendmail component, we can use the phpmailer function to operate it. The example code is as follows:
<?php require('./PHPMailer/class.phpmailer.php'); $phpmailer = new PHPMailer(); $phpmailer->IsSMTP(); $phpmailer->Host = 'smtp.163.com'; $phpmailer->SMTPAuth = true; $phpmailer->Username = ''; $phpmailer->Password = ''; $phpmailer->CharSet = 'utf-8'; $phpmailer->From = ''; $phpmailer->FromName = ''; $phpmailer->Subject = ''; $phpmailer->Body = ''; $phpmailer->AddAddress('never_kiss@163.com','Aseoe'); echo $phpmailer->send()?'发送成功':'发送失败'; ?>
There is no content above. Let’s take a look at the code with content. As follows:
<?php /** 用PHPMailer类来发信 步骤: 0: 引入 1: 实例化 2: 配置属性 3: 调用发送 **/ require('./PHPMailer/class.phpmailer.php'); $phpmailer = new PHPMailer(); /* 设置phpmailer发信用的方式 可用用win下mail()函数来发 可以用linux下sendmail,qmail组件来发 可以利用smtp协议登陆到某个账户上,来发 */ $phpmailer->IsSMTP(); // 用smtp协议来发 $phpmailer->Host = 'smtp.163.com'; $phpmailer->SMTPAuth = true; $phpmailer->Username = ''; //发送邮箱的账号(用163邮箱发信的账号) $phpmailer->Password = ''; //发送邮箱的密码 // 可以发信了 $phpmailer->CharSet='utf-8'; $phpmailer->From = 'never_4ill@163.com'; $phpmailer->FromName = 'neverkill'; $phpmailer->Subject = 'Superstart Aseoe'; $phpmailer->Body = '脚本之家(http://www.jb51.net 专注前端开发与编程设计.'; //设置收信人 $phpmailer->AddAddress('never_4ill@163.com','neverkill'); // 添加一个抄送 $phpmailer->AddCC('1234567','Aseoe'); // 发信 echo $phpmailer->send()?'ok':'fail';
Add a method using the above example:
Directly decompress the phpmailer compressed package and put it in the root directory to run, and put the file directly into the local wamp In the root directory, run 02.php to send the email (assuming the php file is executable) - (if not, create a folder in the root directory and repeat the operation) http://localhost/02.php.
Summary: The above is the entire content of this article, I hope it will be helpful to everyone's study.
Related recommendations:
php uses ffmpeg to implement the method of adding text subtitles to videos
php The definition of parse_str() function and Detailed explanation of usage examples
php method of randomly selecting values from arrays and simple examples
The above is the detailed content of PHP email sending case. For more information, please follow other related articles on the PHP Chinese website!

PHP是一种广泛使用的服务器端脚本语言,在开发Web应用程序时经常用到。它可以轻易地发送和接收电子邮件,这让开发者可以快速构建自己的邮件系统。在本文中,我们将探讨如何使用PHP实现邮件发送和接收的方法。一、发送电子邮件PHP提供了发送电子邮件的许多函数,最常用的是使用SMTP服务器发送电子邮件的PHPMailer类。这个类是使用PHP编写的开源库,具有广泛的

在互联网时代,邮件已经成为人们生活、工作中不可或缺的一个部分。PHP作为一种广泛应用于Web开发领域的语言,邮件发送在Web应用中也是必不可少的。本文将详细介绍PHP邮件发送的相关内容和常见问题汇总。一、PHP邮件发送方法PHPmailer库PHPmailer是一种功能强大的PHP邮件发送类库,它可以轻松地发送HTML格式和纯文本格式的邮件。使用PHPmai

PHP邮件发送指南:如何使用mail函数发送邮件在Web开发中,经常会遇到需要发送邮件的情况,例如注册成功后自动发送欢迎邮件,或者忘记密码后重置密码邮件等。而在PHP中,我们可以使用mail函数来实现邮件的发送功能。本篇文章将教你如何使用mail函数发送邮件。一、准备工作在使用mail函数发送邮件之前,我们需要确保服务器已经配置好了SMTP服务,并且安装了s

如何使用PHP通过邮箱发送电子邮件?随着互联网的发展,电子邮件已经成为了人们日常生活和工作中不可或缺的一部分。而通过编程语言实现自动发送电子邮件的功能,则能极大地提高工作效率和便捷性。在PHP中,我们可以使用SMTP协议通过邮箱发送电子邮件。接下来,我将为大家介绍如何在PHP中实现通过邮箱发送电子邮件的具体方法,并给出代码示例。步骤一:安装必要的库在PHP中

PHP邮件发送函数详细解析:mail、smtp、PHPMailer等函数的邮件发送操作指南,需要具体代码示例一、引言在现代社会中,电子邮件已经成为人们沟通、交流信息的重要工具之一。在Web开发中,我们经常会遇到发送邮件的需求,无论是用户注册验证、密码重置,还是系统通知和营销活动,都需要用到邮件发送功能。PHP作为一种强大的脚本语言,提供了多种发送邮件的函数和

如何处理PHP表单中的邮件发送和接收邮件是现代通讯的重要方式之一,通过在网站的表单中添加邮件发送和接收功能,可以使网站更加实用和互动。本文将介绍如何使用PHP处理表单中的邮件发送和接收。邮件发送在处理邮件发送前,首先确保服务器已经配置好了邮件发送功能。一般来说,邮件发送涉及到SMTP服务器的设置,可以从网络服务提供商或者网络管理员处获取SMTP服务器的地址、

如何使用PHP实现邮件到达和读取功能?随着互联网的迅速发展,电子邮件已经成为人们日常生活和工作中不可缺少的一部分。使用PHP语言来实现邮件到达和读取功能,可以帮助我们更加高效地管理和处理邮件。下面我将详细介绍如何使用PHP来实现邮件到达和读取功能,包括配置SMTP、发送邮件和读取邮件。配置SMTP要发送和读取邮件,首先需要配置SMTP参数。SMTP(Simp

随着互联网和电子邮件的普及,越来越多的人开始使用电子邮件作为主要的沟通工具。PHP是一种流行的服务器端编程语言,也可以用来发送电子邮件。在本文中,我们将介绍如何使用PHP来发送电子邮件。配置SMTP服务器首先,我们需要配置SMTP服务器。SMTP(SimpleMailTransferProtocol)是电子邮件传输的标准协议。大多数邮件服务提供商都会提


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

Safe Exam Browser
Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.

SublimeText3 Linux new version
SublimeText3 Linux latest version

SublimeText3 Chinese version
Chinese version, very easy to use

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Mac version
God-level code editing software (SublimeText3)
