Questions about sending emails using the phpmailer class-php Tutorial

Source: Internet
Author: User
Questions about sending emails using the phpmailer class. [Size12px] has a CreateBody () method in the phpmailer class. the [size] code is as follows: & nbsp; ** & nbsp; * Assemblesthemessagebody. returnsanemptystringonfailure. & nbsp; * @ access questions about sending emails using the phpmailer class.
[Size = 12px] there is a CreateBody () method in the phpmailer class. [/size]
The code is as follows:
/**
* Assembles the message body. Returns an empty string on failure.
* @ Access public
* @ Return string The assembled message body
*/
Public function CreateBody (){
$ Body = '';

If ($ this-> sign_key_file ){
$ Body. = $ this-> GetMailMIME ();
}

$ This-> SetWordWrap ();

Switch ($ this-> message_type ){
Case 'Alt ':
$ Body. = $ this-> GetBoundary ($ this-> boundary [1], '', 'text/plain ','');
$ Body. = $ this-> EncodeString ($ this-> AltBody, $ this-> Encoding );
$ Body. = $ this-> LE. $ this-> LE;
$ Body. = $ this-> GetBoundary ($ this-> boundary [1], '', 'text/html ','');
$ Body. = $ this-> EncodeString ($ this-> Body, $ this-> Encoding );
$ Body. = $ this-> LE. $ this-> LE;
$ Body. = $ this-> EndBoundary ($ this-> boundary [1]);
Break;
Case 'plain ':
$ Body. = $ this-> EncodeString ($ this-> Body, $ this-> Encoding );
Break;
Case 'attachances ':
$ Body. = $ this-> GetBoundary ($ this-> boundary [1], '');
$ Body. = $ this-> EncodeString ($ this-> Body, $ this-> Encoding );
$ Body. = $ this-> LE;
$ Body. = $ this-> AttachAll ();
Break;
Case 'ALT _ attachments ':
$ Body. = sprintf ("-- % s", $ this-> boundary [1], $ this-> LE );
$ Body. = sprintf ("Content-Type: % s; % s ". "\ tboundary = \" % s \ "% s", 'multipart/alternative ', $ this-> LE, $ this-> boundary [2], $ this-> LE. $ this-> LE );
$ Body. = $ this-> GetBoundary ($ this-> boundary [2], '', 'text/plain ',''). $ this-> LE; // Create text body
$ Body. = $ this-> EncodeString ($ this-> AltBody, $ this-> Encoding );
$ Body. = $ this-> LE. $ this-> LE;
$ Body. = $ this-> GetBoundary ($ this-> boundary [2], '', 'text/html ',''). $ this-> LE; // Create the HTML body
$ Body. = $ this-> EncodeString ($ this-> Body, $ this-> Encoding );
$ Body. = $ this-> LE. $ this-> LE;
$ Body. = $ this-> EndBoundary ($ this-> boundary [2]);
$ Body. = $ this-> AttachAll ();
Break;
}

If ($ this-> IsError ()){
$ Body = '';
} Elseif ($ this-> sign_key_file ){
Try {
$ File = tempnam ('', 'mail ');
File_put_contents ($ file, $ body); // TODO check this worked
$ Signed = tempnam ("", "signed ");
If (@ openssl_pkcs7_sign ($ file, $ signed, "file ://". $ this-> sign_cert_file, array ("file ://". $ this-> sign_key_file, $ this-> sign_key_pass), NULL )){
@ Unlink ($ file );
@ Unlink ($ signed );
$ Body = file_get_contents ($ signed );
} Else {
@ Unlink ($ file );
@ Unlink ($ signed );
Throw new phpmailerException ($ this-> Lang ("signing"). openssl_error_string ());
}
} Catch (phpmailerException $ e ){
$ Body = '';
If ($ this-> conditions ){
Throw $ e;
}
}
}

Return $ body;
}


Problem:
The option array object has been passed from the background. you need to set the option array object content to display in a certain format in the body of the sent file. how can I set it ????

------ Solution --------------------

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.