PHP Mailer class calls the remote SMTP server to send mail implementation method, mailersmtp_php tutorial

Source: Internet
Author: User
Tags word wrap how to send mail qmail

The PHP Mailer class calls the remote SMTP server to send the message implementation method, MAILERSMTP


This article explains how the PHP mailer class calls the remote SMTP server to send a message implementation. Share to everyone for your reference, as follows:

PHP Mailer is a very useful PHP e-Mail Send class module, you can call the local SMTP send e-mail, you can also call the remote SMTP send e-mail, but there are some things to be aware of, otherwise it will cause the sending failed, or can not be called at all, This article on my use of this class, encountered problems and solutions to expand, briefly explain the use of PHP Mailer, and considerations.

First download the Phpmailer class library file, download it here, just a resource points. Download Address: http://www.bkjia.com/codes/27188.html

After downloading, place this file, class.phpmailer.php, in a directory of your project and write it where you want to send the message:

<?phprequire ' class.phpmailer.php '; try {$mail = new Phpmailer (true); $body = file_get_contents (' contents.html '); The contents of the message are written to the contents.html page $body = preg_replace ('//////', ' ', $body); Strip backslashes $mail->issmtp (); Tell the class to use SMTP $mail->smtpauth = true; Enable SMTP authentication $mail->port = 25; Set the SMTP server port $mail->host = "mail.yourdomain.com"; Remote SMTP server $mail->username = "yourname@yourdomain.com"; The user name on the remote SMTP server $mail->password = "YourPassword"; The password for the user on your remote SMTP server//$mail->issendmail (); Tell this class to use the SendMail component, use the time if there is no sendmail to put this comment off, otherwise there will be $mail->addreplyto ("yourname@yourdomain.com", "First Last"  );  $mail->from = "fromname@yourdomain.com";  $mail->fromname = "First Last";  $to = "toname@domain.com";  $mail->addaddress ($to);  $mail->subject = "First Phpmailer Message"; $mail->altbody = "To view the message, please use an HTML compatible email viewer!"; Optional, comment outand test $mail->wordwrap = 80;  Set word wrap $mail->msghtml ($body); $mail->ishtml (TRUE);  Send As HTML $mail->send (); Echo ' Message has been sent. ';} catch (Phpmailerexception $e) {echo $e->errormessage ();}? >

Note: The above $mail->issendmail (), need to be commented out, or if there is no sendmail component, will prompt "Could not execute:/var/qmail/bin/sendmail" error !

More interested in PHP related content readers can view the site: "PHP operation skills Summary FOR XML files", "PHP date and Time usage summary", "PHP Object-oriented Programming tutorial", "PHP string (String) Usage Summary", "php+ MySQL database operation Getting Started tutorial and PHP Common database operation Skills Summary

I hope this article is helpful to you in PHP programming.

Articles you may be interested in:

    • PHP sends mail with Phpmailer
    • thinkphp how to send mail using Phpmailer
    • Phpmailer send a message, returns whether the recipient has read the message
    • Phpmailer the solution for sending mail on the server is not normal
    • PHP multiple forms of sending mail (mail qmail mail system Phpmailer Class)
    • A simple way to use PHP to send mail using Phpmailer
    • An example of parsing PHP using Phpmailer to send mail (126.com example)
    • Phpmailer using Tutorials (phpmailer sending mail instance analysis)
    • Sending a mail instance app using Phpmailer
    • Phpmailer message class using Smtp.163.com to send mail methods

http://www.bkjia.com/PHPjc/1106115.html www.bkjia.com true http://www.bkjia.com/PHPjc/1106115.html techarticle The PHP Mailer class calls the remote SMTP server to send the message implementation method, MAILERSMTP This article describes the PHP mailer class calls the remote SMTP server send mail implementation method. Share for the big ...

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