Home >Backend Development >PHP Tutorial >Detailed explanation of the problem of sending emails in php, detailed explanation of sending emails in php_PHP tutorial

Detailed explanation of the problem of sending emails in php, detailed explanation of sending emails in php_PHP tutorial

WBOY
WBOYOriginal
2016-07-13 09:49:06738browse

Detailed explanation of the problem of sending emails in php, Detailed explanation of sending emails in php

php implements sending emails, which is generally implemented by the open source project PHPMailer. So besides this, what else is there? A good project?

Solution:

Use SMTP protocol to send emails

Send emails using its built-in email class in CodeIgniter

$this->load->library('email');

$to = "aa@bb.cc";
$subject = "test";
$message = "hello!";

$config["protocol"]   = "smtp";
$config["smtp_host"]  = "smtp.163.com";
$config["smtp_user"]  = "username@163.com";
$config["smtp_pass"]  = "password";
$config["mailtype"]   = "html";
$config["validate"]   = true;
$config["priority"]   = 3;
$config["crlf"]     = "/r/n";
$config["smtp_port"]  = 25;
$config["charset"]   = "utf-8";
$config["wordwrap"]   = TRUE;
$this->email->initialize($config);
$this->email->from('xxxx@163.com', 'xxxx');
$this->email->to($to);   
$this->email->subject($subject);
$this->email->message($message); 
$this->email->send();

Sending emails this way does not require installing any software, but it does require you to write more code and be familiar with SMTP.

But if you don’t write it yourself, but directly use ready-made code written by others, then this method is undoubtedly the most trouble-free:

You don’t need to build your own SMTP server, and you don’t need to write a lot of code.

Summary:

Currently, PHP comes with the sendmail-based mail() function to send emails, but the prerequisite is that sendmail must be installed on the server. Many server space providers do not install sendmail mail servers. So there are certain limitations.

So there are currently many open source components for sending emails based on SMTP. The most famous one is probably phpMailer. You already know this and I won’t go into details. I’ll talk about other methods here.
1. XPertMailer: This is also an open source PHP component for sending emails. It is similar to phpMailer and very convenient. Here is its official website (http://xpertmailer.sourceforge.net/). I have personally tested it and it is really good.

2. JMail: JMail is a component under Windows, but PHP supports calling it through COM. This is also a solution, but the premise is that if the Web Server runs on Windows, it can be considered, otherwise it is better to forget it.

3. There are many mail classes based on SMTP written by many people on the Internet, which are also usable, but the supported functions are relatively simple. If the requirements are not high, you can also consider it.

4. Here are 20 more well-known open source PHP components for sending emails. I have not tested them one by one, so I have no opinion. You can try it yourself. Paste the address here:
Introducing 20 PHP mail open source projects

The above is the entire content of this article, I hope you all like it.

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/1020537.htmlTechArticleDetailed explanation of the problem of sending emails in php. Detailed explanation of sending emails in php. PHP implements sending emails. Generally, the open source project PHPMailer is commonly used. Realized, so besides that, are there any other good projects...
Statement:
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