Has anyone ever written a mail program that uses pear mail to send emails with attachments? Can you give me an example?-php Tutorial

Source: Internet
Author: User
Has anyone ever written a mail program that uses pear mail to send emails with attachments? Can you give me an example? Use Mail. php & lt;? in pear ;? Phprequire_once & nbsp; & #39; varphplibphpMail. php & #39; $ conf [& #39; mail & #39;] & nbsp; array (has someone written a mail program that uses pear mail to send emails with attachments? Can you give me an example?
Use Mail. php in pear
Require_once '/var/php/lib/php/Mail. php ';

$ Conf ['mail'] = array (
'Host' => '2014. com', // smtp server address, which can be an IP address or domain name
'Auth' => true, // true indicates that the smtp server needs to be verified. false indicates that the code does not need to be verified.
'Username' => 'ABC', // User name
'Password' => 'ABC' // password
);

/***
* You can use the $ headers array To define the content of the mail header. for example, you can use $ headers ['reply-to'] To define the Reply address.
* In this way, you can easily customize the mail header to be sent.
***/
$ Headers ['from'] = '[email protected]'; // mail address
$ Headers ['to'] = [email protected]; // recipient address
$ Headers ['subobject'] = 'Hello, everyone'; // mail title
$ Mail_object = & Mail: factory ('smtp ', $ conf ['mail']);

$ Body = "haha .. I succeeded !!!! "; // Body of the email

$ Mail_res = $ mail_object-> send ($ headers ['to'], $ headers, $ body); // send

If (PEAR: isError ($ mail_res) {// Check the error
Die ($ mail_res-> getMessage ());
} Else {
Echo "send successful! ";
}
?>

I successfully sent the above, but I don't know how to do it if there is an attachment. you guys can help me check it out.

------ Solution --------------------
MIME processing class to use PEAR...

As for how to handle it.
You need to master some SMTP and related RFC protocols.
------ Solution --------------------
Use JSP worker's ~~
Yes ~~

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.