Php 发送电子邮件头附件的语法

Php 发送电子邮件头附件的语法,php,email,pear,Php,Email,Pear,可能重复: 我想用PHP发送一封电子邮件,使用生成的附件(不是服务器上的文件),我对语法很好奇 <?php @require_once "Mail.php"; $from = "foo@me.com>"; $to = "blah@me.com>"; $subject = "Hi!"; $body = "Attached is the file\n\n"; $attachment = header( 'Content-Type: text/csv' ); $attachme

可能重复:

我想用PHP发送一封电子邮件,使用生成的附件(不是服务器上的文件),我对语法很好奇

<?php
@require_once "Mail.php";

$from = "foo@me.com>";
$to = "blah@me.com>";
$subject = "Hi!";
$body = "Attached is the file\n\n";

$attachment = header( 'Content-Type: text/csv' );
$attachment = $attachment.header( 'Content-Disposition: attachment;filename=example.csv');
$attachment =  'transactionid,valid,fname,lname,email,studentid,status
            "654","1","First Name","Last Name","Email@me.com","1000000"';
$body = $body.$attachment;


$headers = array ('From' => $from,
'To' => $to,
'Subject' => $subject);


$smtp = @Mail::factory('smtp', array('host' => $host,
                                    'port' => $port,
                                    'auth' => true,
                                    'username' => $mail_username,
                                    'password' => $mail_password));

$mail = @$smtp->send($to, $headers, $body);
if (@PEAR::isError($mail)) {
   echo("<p>" . $mail->getMessage() . "</p>");
} else {
   echo("<p>Message successfully sent!</p>");
}
?>

然后更换以下部件:

if ($mime->addAttachment($file,'application/pdf')){


请参阅上的文档
header()
函数与文本处理/邮件无关。而
是连接运算符,不用于方法调用。@mario它不是该运算符的副本,该示例显示从服务器上的文件进行附加。。。如何使用生成的cvs字符串进行附加?我们还有几百个副本。如果不是手册,请使用搜索功能。@mari给我看一份副本,我找不到任何类似的问题。。。所有问题都是关于从服务器附加文件。。。不是生成的文件。。。请阅读完整的问题。您尝试过哪些搜索?是时候查看手册了吗?谢谢!这正是我要找的!
$file =  'transactionid,valid,fname,lname,email,studentid,status
            "654","1","First Name","Last Name","Email@me.com","1000000"';
if ($mime->addAttachment($file,'text/csv', 'example.csv', false)){