Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/email/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/linux/27.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 我需要自动将文件附加到出站电子邮件…帮助_Php_Email_Attachment - Fatal编程技术网

Php 我需要自动将文件附加到出站电子邮件…帮助

Php 我需要自动将文件附加到出站电子邮件…帮助,php,email,attachment,Php,Email,Attachment,我有一个表单(input.html),由在这家公司的五个不同部门工作的人填写。提交表单后,它将发布到output.php Output.php做了很多事情: 首先,它将所有输入信息显示为完整的表单。(只是向他们展示他们完成的文档) 它还基于input.html中的两个输入字段创建了一个名为unique_file.html的文件 接下来,output.php根据input.html中选择的另一个输入字段向五个电子邮件组之一发送了一封电子邮件 最后(现在),我需要唯一的_file.html作为电子邮

我有一个表单(input.html),由在这家公司的五个不同部门工作的人填写。提交表单后,它将发布到output.php

Output.php做了很多事情: 首先,它将所有输入信息显示为完整的表单。(只是向他们展示他们完成的文档)

它还基于input.html中的两个输入字段创建了一个名为unique_file.html的文件

接下来,output.php根据input.html中选择的另一个输入字段向五个电子邮件组之一发送了一封电子邮件

最后(现在),我需要唯一的_file.html作为电子邮件的附件。这是我的问题

我找到了上传文件的脚本,我找到了很多关于上传文件的教程,但我只想将unique_file.html附加到我发送的电子邮件中,我不知道如何实现


有人能告诉我从哪里开始的正确方向吗?我肯定错过了这条船,我可能已经看到了,但没有意识到。

如果您可以使用Zend_框架,您可以轻松地将文件附加到电子邮件,即

$mail = new Zend_Mail();

$at = new Zend_Mime_Part($myImage);
$at->type        = 'image/gif';
$at->disposition = Zend_Mime::DISPOSITION_INLINE;
$at->encoding    = Zend_Mime::ENCODING_8BIT;
$at->filename    = 'test.gif';

$mail->addAttachment($at);

$mail->send();
看,, 您应该能够通过使用pear包和普通函数附加文件

但是我认为使用Zend框架的解决方案更直接

干杯。

我觉得这是最好的。安:

require_once('../class.phpmailer.php');

$mail             = new PHPMailer(); // defaults to using php "mail()"

$body             = file_get_contents('contents.html');
$body             = eregi_replace("[\]",'',$body);

$mail->AddReplyTo("name@yourdomain.com","First Last");

$mail->SetFrom('name@yourdomain.com', 'First Last');

$mail->AddReplyTo("name@yourdomain.com","First Last");

$address = "whoto@otherdomain.com";
$mail->AddAddress($address, "John Doe");

$mail->Subject    = "PHPMailer Test Subject via mail(), basic";

$mail->AltBody    = "To view the message, please use an HTML compatible email viewer!"; // optional, comment out and test

$mail->MsgHTML($body);

$mail->AddAttachment("images/phpmailer.gif");      // attachment
$mail->AddAttachment("images/phpmailer_mini.gif"); // attachment

if(!$mail->Send()) {
  echo "Mailer Error: " . $mail->ErrorInfo;
} else {
  echo "Message sent!";
}