PHP uses the Jmail component to send emails

Source: Internet
Author: User
Friends who have learned asp may know that the jmail component uses a common mailbox sending function in asp. to call the jmail function in php, we need to use the com component for operations, let's first introduce the format. the code is as follows: $ Jmail... friends who have learned asp may know that the jmail component uses a common mailbox sending function in asp. to call the jmail function in php, we need to use the com component for operations, let's first introduce the format. the code is as follows:

$ Jmail = new com ("Jmail. message "); // instantiate a Jmail object $ Jmail-> SiLent = true; // if it is set to True, Jmail will not prompt errors and will only return True and False $ Jmail-> LogGing = false; // whether to enable logs $ Jmail-> CharSet = "UTF8 "; // Set the string encoding $ Jmail-> ContentType = "Text/html"; // The Mail format is HTML format $ Jmail-> MailServerUsername = 'mail user name '; $ Jmail-> MailServerPassword = 'mail password '; $ Jmail-> MailServerAddress = 'smtp server address' $ Jmail-> FromName = 'sender name '; $ Jmail-> From = 'sender address'; $ Jmail-> AddRecipient ('recipient address'); $ html = 'Email body '; $ Jmail-> Subject = 'Email title'; $ Jmail-> Body = $ html; $ JmailError = $ Jmail-> Send ($ Jmail-> MailServerAddress ); if ($ JmailError) {echo 'sent successfully ';}

The instance code is as follows:

 Silent = true; // block exception errors $ jmail-> charset = 'gb2312'; // Otherwise, Chinese characters will be garbled $ jmail-> From = 'web535000 @ 163.com '; // theoretically, it can not be the same as the sender address, but it cannot be used for several attempts with 163. you can change it to the same one. $ jmail-> FromName = 'botest '; $ jmail-> AddRecipient ('abc1 @ 163.com '); // you can add multiple email recipients. // $ jmail-> AddRecipient ('abc2 @ 163.com '); // $ jmail-> AddRecipient ('abc3 @ 163.com '); $ jmail-> Subject = 'Email test. '; $ jmail-> Body =' this is test email. '; $ jmail-> MailServerUserNam E = 'web535000 @ 163.com '; // email sending account $ jmail-> MailServerPassword = '2016 '; // try {$ email = $ jmail-> Send ('smtp .163.com '); if ($ email) echo 'sent successfully '; else echo 'sending failed';} catch (Exception $ e) {echo $ e-> getMessage () ;}?>


Article address:

Reprint at will ^ please include the address of this 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.