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 ~~