PEAR Handbuch | ||
---|---|---|
Zurück | Nach vorne |
A class to enable easy creation of complex multipart emails. If what you're after is a simple API for creating such emails, then this class will probably suffice. If on the other hand you're after a higher degree of control over the email, then you might want to look at using mimePart
string $data - The image file name or the image data itself
string $c_type - The content type of the image or file. Default is application/octet-stream.
string $name - The filename of the image. Only used, if $file contains the image data.
boolean $isfile - Whether $file is a filename or not. Default is true.
string $data - The image file name or the image data itself
string $c_type - The content type of the image or file. Default is application/octet-stream.
string $name - The filename of the image. Only used, if $file contains the image data.
boolean $isfile - Whether $file is a filename or not. Default is true.
string $encoding - Type of transfer encoding to use for the file data. Defaults is base64. For text based files (eg. scripts/html etc.) this could be given as quoted-printable.
This function should be called once you have added the text/html/images/attachments. It builds the email and returns it. It does not send it. To send what this function returns (in conjunction with the headers() function) you would need to use the Mail_*::send() -function
array $param - An associative array of parameters. These parameters affect the way the email is built.
$param["text_encoding"] - Type of encoding to use for the plain text part of the email. Default is 7bit.
$param["html_encoding"] - Type of encoding for the HTML part of the email. Default is quoted-printable.
$param["7bit_wrap"] - Number of characters after which text is wrapped. SMTP stipulates maximum line length of 1000 characters including CRLF. Default is 998 (CRLF is appended to make up to 1000).
$param["text_charset"] - The character set to use for the plain text part of the email. Default is iso-8859-1.
$param["html_charset"] - The character set to use for the HTML part of the email. Default is iso-8859-1.
Returns an array with the headers needed to prepend to the email (MIME-Version and Content-Type). Please note that the function get() has to be called before calling headers().
array $headerEx - Additional headers, the format of the argument is $array['header-name'] = 'header-value'
array - An associative array with the mime headers and the additional headers. The return value can directly passed to the second parameter of Mail_*::send().
<?php include('Mail.php'); include('Mail/mime.php'); $text = 'Text version of email'; $html = '<html><body>HTML version of email</body></html>'; $file = '/home/richard/example.php'; $crlf = "\r\n"; $hdrs = array( 'From' => 'you@yourdomain.com', 'Subject' => 'Test mime message' ); $mime = new Mail_mime($crlf); $mime->setTXTBody($text); $mime->setHTMLBody($html); $mime->addAttachment($file, 'text/plain'); $body = $mime->get(); $hdrs = $mime->headers($hdrs); $mail =& Mail::factory('mail'); $mail->send('postmaster@localhost', $hdrs, $body); ?> |
Zurück | Zum Anfang | Nach vorne |
Nach oben | Mail_mimePart |