Detailed explanation of the problem of sending emails in php
This article mainly introduces the relevant information about the detailed explanation of the problem of sending emails in php. Friends who need it can refer to it
php implements sending emails. It is generally implemented by the open source project PHPMailer. So besides this, are there any other good projects?
Solution:
Use SMTP protocol to send emails
Use CodeIgniter’s built-in email class to send emails
?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
$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();
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
$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();
|
There is no need to install any software to send emails in this way, 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:
There is no need to build an SMTP server yourself, nor do you need to write a lot of code.
Summary:
Currently, PHP comes with the mail() function based on sendmail to send emails, but the premise 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 tested it myself and it is really good. OK
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 open source projects for sending emails via PHP
The above is the entire content of this article, I hope you all like it.
http://www.bkjia.com/PHPjc/1020282.htmlwww.bkjia.comtruehttp: //www.bkjia.com/PHPjc/1020282.htmlTechArticleDetailed explanation of the problem of sending emails in php This article mainly introduces the relevant information of the detailed explanation of the problem of sending emails in php, which is needed Friends can refer to php to implement sending emails. The most commonly used one is open source...