时间:2021-07-01 10:21:17 帮助过:3人阅读
This is a html message ?> 添加多个附件 This is a html message
正如上一节,添加多个附件是rasy与调用addAttachment了。在这个例子中,我会发送一个带有两个文本附件的电子邮件。
include('Mail.php');
include('Mail/mime.php');
// Constructing the email
$sender = "Leigh
$recipient = "Leigh
$subject = "Test Email"; // Subject for the email
$text = 'This is a text message.'; // Text version of the email
$html = '
$crlf = "n";
$headers = array(
'From' => $sender,
'Return-Path' => $sender,
'Subject' => $subject
);
// Creating the Mime message
$mime = new Mail_mime($crlf);
// Setting the body of the email
$mime->setTXTBody($text);
$mime->setHTMLBody($html);
// Add an attachment
$file = "Hello World!"; // Content of the file
$file_name = "Hello text.txt"; // Name of the Attachment
$content_type = "text/plain"; // Content type of the file
$mime->addAttachment ($file, $content_type, $file_name, 0); // Add the attachment to the email
// Add a second attachment
$file = "Hello World! Again :)"; // Content of the file
$file_name = "Hello text 2.txt"; // Name of the Attachment
$content_type = "text/plain"; // Content type of the file
$mime->addAttachment ($file, $content_type, $file_name, 0); // Add the attachment to the email
$body = $mime->get();
$headers = $mime->headers($headers);
// Sending the email
$mail =& Mail::factory('mail');
$mail->send($recipient, $headers, $body);
?>
http://www.bkjia.com/PHPjc/444991.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/444991.htmlTechArticle添加附件 添加一个附件 添加一或多个附件很简单,添加附件,是通过调用addAttachment方法,这种方法可以多次调用添加多个attachemnts。 布尔...