Tutorial | Application instance PHP write the program to send the attachment (i)
Heyes
?
Error_reporting (63);
Include (' Class.html_mime_mail.inc ');
/***************************************
* * Example of usage.
***************************************/
/***************************************
* * Read the file background.gif into
* * $backgrnd.
***************************************/
$filename = ' background.gif ';
$backgrnd = fread ($fp = fopen ($filename, ' R '), FileSize ($filename));
Fclose ($FP);
/***************************************
* * Read the file test.zip into $attachment.
***************************************/
$filename = ' Example.zip ';
$attachment = fread ($fp = fopen ($filename, ' R '), FileSize ($filename));
Fclose ($FP);
/***************************************
* * Create the Mail object. Optional headers
* * argument. Don't put From:here, this
* * 'll is added when $mail->send
***************************************/
$mail = new Html_mime_mail ("x-mailer:html MIME Mail class\r\n");
/***************************************
* * If sending an HTML email, then
* * Two variables specify the text and
* * HTML versions of the mail. Don ' t
* * have to is named as these are. Just
* * Make sure the names tie into to the
* * $mail->add_html () command further down.
***************************************/
$text = ' This is a test. ';
$html = '
/***************************************
* * ADD the text, HTML and embedded images.
* * Each embedded image has to is added
* * using $mail->add_html_image () before
* * Calling $mail->add_html (). The name
* * of the image should match exactly
* * (case-sensitive) to the name in the HTML.
***************************************/
$mail->add_html_image ($backgrnd, ' background.gif ', ' image/gif ');
$mail->add_html ($html, $text);
/***************************************
* * If not sending an HTML email, then
* * is used to set the plain text
* * Body of the email.
***************************************/
$mail->body = ' fsss ';
/***************************************
* * is used to add a attachment to
* * the email.
***************************************/
$mail->add_attachment ($attachment, ' example.zip ', ' application/octet-stream ');
/***************************************
* * builds the message.
***************************************/
$mail->build_message ();
/***************************************
* * sends the message. $mail->build_message ()
* * is seperate to $mail->send
* * Same email can be sent many
* * Differing recipients simply by putting
* * $mail->send () in a loop.
***************************************/
$mail->send (', ' szw@phpexe.com ', ' from Name ', ' szw@phpexe.com ', ' Subject ', ');
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.