1500字范文,内容丰富有趣,写作好帮手!
1500字范文 > php mail带附件 Pear Mail 发送邮件带附件_PHP教程

php mail带附件 Pear Mail 发送邮件带附件_PHP教程

时间:2018-08-03 19:30:01

相关推荐

php mail带附件 Pear Mail 发送邮件带附件_PHP教程

?>

添加多个附件正如上一节,添加多个附件是rasy与调用addAttachment了。在这个例子中,我会发送一个带有两个文本附件的电子邮件。

include(‘Mail.php’);

include(‘Mail/mime.php’);

// Constructing the email

$sender = “Leigh “; // Who your name and email address

$recipient = “Leigh “; // The Recipients name and email address

$subject = “Test Email”; // Subject for the email

$text = ‘This is a text message.’; // Text version of the email

$html = ‘

This is a html message

‘; // HTML version of the email

$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);

?>

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。