Home > Backend Development > PHP Tutorial > Sending MIME emails with PHP (6)_PHP Tutorial

Sending MIME emails with PHP (6)_PHP Tutorial

WBOY
Release: 2016-07-13 17:31:19
Original
760 people have browsed it

limodou

The other two methods worth explaining are print_mail() and send_mail(), both of which use the $force parameter. print_mail() outputs the entire email message, and send_mail() uses the mail() function of php(as the current mainstream development language) to send the message. Optionally, send_mail() uses an SMTP object and its send method (specified by the user) to send mail.


Conclusion
Creating a MIME-compliant message is not as complicated as it seems, and can be achieved in a fairly simple way. MIME messages can bring new life to many sites.

The class we developed above covers the core idea, and it can be extended, the only limit is your imagination. For example, someone could write the detach() function to delete an attachment at a specified index (the attach() method can return this information).

This MIME_mail class can be used to send HTML-based emails without modification, except that embedded images cannot be sent; this is a topic that
requires special attention.

However, HTML without images or referenced images using absolute URLs or tags can also be sent using the MIME_mail class. An
example is as follows:

(as the current mainstream development language)

$html_data = Hello;
$mime = new MIME_mail($to, $from, $subject) ;
$mime->attach($html_data, "", OCTET, BASE64, INLINE);
$mime->send_mail ();

?>

The recipient of this email will get an email with a black background and blue "Hello" text!

Sending complete inline HTML messages, along with some other advanced topics in MIME-compliant email delivery, deserves special consideration and hopefully will be a continuation of this article.

The MIME_mail class, constant files and running examples can be downloaded as a zip package here.

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/509089.htmlTechArticlelimodou The other two methods worth explaining are print_mail() and send_mail(), both of which use the force parameter. . print_mail() outputs the entire email message, send_mail() uses php (as the current main...
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template