Sending emails using PHP's mail function The mail() function connects to the mail server, interacts with the server and sends mail using the SMTP protocol Notice: 1. The mail function does not support the esmtp protocol, that is, it can only be sent directly but not logged in 2. As we know from the previous point, we can only send directly to the final receiving server address, and this address needs to be specified in php.ini Here we take NetEase mailbox as an example, first find the server address: Then write the address into php.ini, open php.ini, find mail function, fill in one of the addresses, and turn on the sender settings: Restart Apache and open a command prompt as an administrator: httpd -k restart At this point the changes to php.ini will take effect. Now let's use the mail function: Syntax: mail(to, subject, message, headers, parameters)
The following is the code section: <?php $to = '[email protected]'; $sub = 'say hello'; $msg = 'hello, php!'; $from = "From: <eyes++>"; mail($to,$sub,$msg,$from); Effect display: Note: Because the server address of NetEase mailbox is used in the above demonstration, and it does not provide forwarding service, you can only send emails to NetEase mailbox. If you want to send emails to QQ mailbox, you need to set the QQ mailbox server address in php.ini. If you need to send emails to any mailbox, you need to install an anonymous smtp server as a transit. Perhaps I will update the relevant content in this blog later. Summarize This is the end of this article about using the mail() function in PHP to implement the function of sending emails. For more relevant content about php mail() sending emails, please search 123WORDPRESS.COM’s previous articles or continue to browse the following related articles. I hope everyone will support 123WORDPRESS.COM in the future! You may also be interested in:
|
<<: Detailed explanation of MySQL transaction processing usage and example code
>>: Detailed explanation of common commands in Docker repository
Preface: Partitioning is a table design pattern. ...
Preface: When we want to clear a table, we often ...
inline-flex is the same as inline-block. It is a ...
Flex layout is a commonly used layout method nowa...
1. Download nginx [root@localhost my.Shells]# doc...
Table of contents 1. Introduction 2. Main text 2....
How to determine what this points to? ①When calle...
Common Convention Tags Self-closing tags, no need...
MTR stands for Mini-Transaction. As the name sugg...
trigger: Trigger usage scenarios and correspondin...
Table of contents Problems encountered during dev...
Ubuntu16.04 install and uninstall pip Experimenta...
Table of contents 1. Use of arrow functions 1. Fr...
1. Multi-header table code Copy code The code is a...
There are many differences between IE6 and IE7 in ...