Has anyone written a mail program with an attachment in the Mail class of pear mail? Can you give me an example?

Source: Internet
Author: User
Has anyone written a mail program with an attachment in the Mail class of pear mail? Can you give me an example?
Using the mail.php in pear
Require_once '/var/php/lib/php/mail.php ';

$conf [' mail '] = Array (
' Host ' = ' 163.com ',//SMTP server address, can use IP address or domain name
' Auth ' = True,//true indicates that the SMTP server requires authentication, and false code does not require
' username ' = ' abc ',//user name
' Password ' = ' abc '//Password
);

/***
* Using the $headers array, you can define the contents of the message header, such as using $headers[' reply-to '] to define the reply address
* In this way, it is easy to customize the message header for outgoing mail
***/
$headers [' from '] = ' [email protected] '; Sending address
$headers [' to '] = [email protected]; Delivery address
$headers [' Subject '] = ' hello,everyone '; Message header
$mail _object = &mail::factory (' smtp ', $conf [' Mail ']);

$body = "haha. I did it!!!! "; Message body

$mail _res = $mail _object-> Send ($headers [' to '], $headers, $body); Send

if (Pear::iserror ($mail _res)) {//Detect error
Die ($mail _res-> getMessage ());
} else {
echo "Send successful!";
}
?>

I use the above to send success, but if there are attachments do not know how to do, you heroes help me to see

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

As to how to deal with.
You need to master some SMTP and related RFC protocols.
------Solution--------------------
Use JSP to write ~ ~
have ~ ~
  • Related Article

    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.