Phpmailer:featured email transfer class for PHP

Source: Internet
Author: User
Keywords Phpmailer:featured email transfer class for PHP
Tags word wrap

Phpmailer:featured email transfer class for PHP
Phpmailer is a useful class for sending mail to PHP. It supports the use of SMTP servers to send mail, while supporting Sendmail, QMail, Postfix, Imail, Exchange, Mercury, Courier and other mail servers. SMTP server also supports authentication, multi-SMTP send (but not very clear what is used). Mail send can include multiple to, CC, BCC and reply-to, support text and HTML two kinds of message format, can be wrapped automatically, support various formats of attachments and pictures, Custom message first-class basic mail functionality.

Because PHP contains only a mail function, so phpmailer is a big enhancement, I believe it can meet the needs of many people, hehe. It consists of two classes of files: class.smtp.php for implementing the class.phpmailer.php and SMTP implementations of the Send mail feature. Then there are files that can implement a variety of error outputs, as well as very detailed documentation. Software releases follow the LGPL protocol.

The use is also very simple, see the following example to understand:

Require ("class.phpmailer.php");

$mail = new Phpmailer ();

$mail->issmtp (); Send via SMTP
$mail->host = "smtp1.site.com;smtp2.site.com"; SMTP servers
$mail->smtpauth = true; Turn on SMTP authentication
$mail->username = "Jswan"; SMTP username
$mail->password = "secret"; SMTP Password
' Www.cncms.com
$mail->from = "from@email.com";
$mail->fromname = "Mailer";
$mail->addaddress ("josh@site.com", "Josh Adams");
$mail->addaddress ("ellen@site.com"); Optional name
$mail->addreplyto ("info@site.com", "Information");

$mail->wordwrap = 50; Set word Wrap
$mail->addattachment ("/var/tmp/file.tar.gz"); Attachment
$mail->addattachment ("/tmp/image.jpg", "new.jpg");
$mail->ishtml (TRUE); Send As HTML

$mail->subject = "Here is the Subject";
$mail->body = "This is the HTML Body";
$mail->altbody = "This is the text-only body";

if (! $mail->send ())
{
echo "Message is not sent

";
echo "Mailer Error:". $mail->errorinfo;
Exit
}

echo "Message has been sent";


See Phpmailer's homepage: http://phpmailer.sourceforge.net/

  • 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.