PearMail发送邮件带附件_PHP教程
内容导读
互联网集市收集整理的这篇技术教程文章主要介绍了PearMail发送邮件带附件_PHP教程,小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含5630字,纯文字阅读大概需要9分钟。
内容图文
![PearMail发送邮件带附件_PHP教程](/upload/InfoBanner/zyjiaocheng/173/32cf8fb5a2ed4e94a3ef2fd57fddb715.jpg)
添加一个附件
添加一或多个附件很简单,添加附件,是通过调用addAttachment方法,这种方法可以多次调用添加多个attachemnts。
<span title="boolean addAttachment (string $file, string [$c_type = "application/octet-stream'], string [$name = ], boolean [$isfile = TRUE], string [$encoding = 'base64'])" style="background-color: #fff" closure_hashcode_6zmbqs="21">布尔addAttachment($文件的字符串,字符串[$ c_type ='应用程序/八位字节流'],串[$名称=],布尔[$ isfile =真],字符串[$编码='一个base64'])
变量:
$文件:要么变量包含一个文件的内容,或文件本身的路径
$ c_type:内容类型,这意味着,例如文件的MIME类型。 text / plain的,文字/ CSV格式,应用/ PDF格式
$名称:该文件的名称,您希望它出现在电子邮件,这应该是唯一的
$ isFile:是否变量$文件是对文件或文件的内容的路径
$编码:这通常应为默认离开,除非你知道你在做什么
附件可以是在一个变量,或在服务器上的文件中存储的文件系统。<span title="in this first example I will create a small text file named "hello text.txt', with the words 'Hello World!'" closure_hashcode_6zmbqs="30">在这第一个例子中,我将建立一个小型文本文件名为'你好text.txt'改为'你好世界!也。
This is a html message ?>
添加多个附件
正如上一节,添加多个附件是rasy与调用addAttachment了。在这个例子中,我会发送一个带有两个文本附件的电子邮件。
This is a html message
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。 布尔...
内容总结
以上是互联网集市为您收集整理的PearMail发送邮件带附件_PHP教程全部内容,希望文章能够帮你解决PearMail发送邮件带附件_PHP教程所遇到的程序开发问题。 如果觉得互联网集市技术教程内容还不错,欢迎将互联网集市网站推荐给程序员好友。
内容备注
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 gblab@vip.qq.com 举报,一经查实,本站将立刻删除。
内容手机端
扫描二维码推送至手机访问。