A friend who has 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 it.
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 the error and only return True and False.
- $ Jmail-> LogGing = false; // whether to enable LogGing
- $ Jmail-> CharSet = "UTF8"; // sets the string encoding.
- $ Jmail-> ContentType = "Text/html"; // The email format is HTML.
- $ Jmail-> MailServerUsername = 'Email sending username ';
- $ 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:
-
- $ Jmail = new COM ('jmail. message') or die ('unable to call the JMail components ');
- $ Jmail-> silent = true; // block exception errors
- $ Jmail-> charset = 'gb2312'; // Otherwise, Chinese characters will be garbled.
- $ Jmail-> From = 'web535000 @ 163.com '; // theoretically, it is not the same as the sender address, but it cannot be used for several attempts using 163.
- It can be the same.
- $ 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-> MailServerUserName = 'web535000 @ 163.com '; // mail account
- $ Jmail-> MailServerPassword = '000000'; // account password
- Try {
- $ Email = $ jmail-> Send ('smtp .163.com ');
- If ($ email) echo 'sent successfully ';
- Else echo 'sending failed ';
- } Catch (Exception $ e ){
- Echo $ e-> getMessage ();
- }
- ?>