Swift Mailer PHP Mail class

Source: Internet
Author: User
I. Brief introduction of Swift Mailer

Swift Mailer is a PHP mail-sending class. It does not rely on the mail () function that comes with PHP because the function consumes a high amount of system resources when sending multiple messages. Swift communicates directly with the SMTP server, with very high transmission speed and efficiency.

Features of Swift Mailer:

1. Use SMTP, SendMail, Postfix, or you can customize the transport implementation to send e-mail

2. Servers requiring user name and password and or encryption support

3, from the head injection attack protection does not request the content of data

4. Send MIME-compatible Html/multipart Mail

5. Use the event-driven plug-in method to customize the library

6. Low memory consumption when handling large attachments and embedded/embedded images

7, Swiftmailer e-mail efficiency is much higher than phpmailer, easy to use.

Ii. Use of Swift Mailer

Require_once ' lib/swift_required.php '; function SendMail () {/* $transport = swift_smtptransport::newinstance (' Smtp.163.com ', $transport->setusername (' username@163.com '); $transport->setpassword (' password '); $ Transport = swift_sendmailtransport::newinstance ('/usr/sbin/exim-bs '); $transport = Swift_mailtransport:: Newinstance (); */$transport = swift_smtptransport::newinstance (' smtp.163.com '); $transport->setusername (' Username@163.com '); $transport->setpassword (' password '); $mailer = Swift_mailer::newinstance ($transport); $ message = Swift_message::newinstance (); $message->setfrom (Array (' username@163.com ' = ' name ')); $message Setto (Array (' whoever@163.com ' = ' mr.right ', ' whoever@qq.com ' = ' mr.wrong ')); $message->setsubject ("This is a subject "); $message->setbody (' Here is the message ', ' text/html ', ' utf-8 '); ' Text/plain ' $message->attach (Swift_attachment::frompath (' pic.jpg ', ' Image/jpeg ')->setfilename (' Rename_ Pic.jpg ') try{$mailer->send ($message);} CatCH (swift_connectionexception $e) {echo ' There is a problem communicating with SMTP: '. $e->getmessage ();}} 

Project Address: http://swiftmailer.org/

  • Related Article

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.