This article mainly introduces the problem of PHP to send a message to explain the relevant information, the need for friends can refer to the
PHP implementation to send mail, commonly used is open source project Phpmailer to achieve, then otherwise, what other good projects?
Workaround:
Use the SMTP protocol to send mail.
In CodeIgniter, use its built-in message class to send mail
?
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 (); |
Sending a message in this way requires no software, but you need to write more code and be familiar with SMTP.
But if you don't write it yourself, it's the easiest way to use the ready-made code written by someone else:
You don't need to build your own SMTP server, and you don't need to write a lot of code.
Summarize:
PHP now comes with the SendMail mail () function to send mail, but only if the server must be installed SendMail, many server space providers are not installed SendMail mail server. So there is a certain limit.
So there are many open source components based on SMTP to send mail, the most famous should be Phpmailer, this you already know I will not say more, I said here to talk about other methods.
1, Xpertmailer: This is also open source php send mail components, and Phpmailer similar, also very convenient, here is its official website (http://xpertmailer.sourceforge.net/), I personally tested, really very good.
2, Jmail:jmail is a component under Windows, but PHP support through COM to call it, this is a solution, but the premise is that if the Web server is running in Windows can be considered, or forget it.
3, there are many people on the internet based on the SMTP mail class, but also can be used, but the support function is relatively simple. If the request is not high, you can also consider.
4, there are 20 more well-known open source PHP to send mail components, I do not have one by one test, do not express views. You can try it on your own. Put the address here:
Introduction to 20 php send mail mail open source project
The above mentioned is the entire content of this article, I hope you can enjoy.