很可能与你列出的所有3个库(PHPMailer的,PEAR和Swiftmailer)做。
对于PHPMailer的,你可以看到一个tutorial here:
require_once '../class.phpmailer.php';
$mail = new PHPMailer(true); //defaults to using php "mail()"; the true param means it will throw exceptions on errors, which we need to catch
try {
$mail->AddReplyTo('[email protected]', 'First Last');
$mail->AddAddress('[email protected]', 'John Doe');
$mail->SetFrom('[email protected]', 'First Last');
$mail->AddReplyTo('[email protected]', 'First Last');
$mail->Subject = 'PHPMailer Test Subject via mail(), advanced';
$mail->AltBody = 'To view the message, please use an HTML compatible email viewer!'; // optional - MsgHTML will create an alternate automatically
$mail->MsgHTML(file_get_contents('contents.html'));
$mail->AddAttachment('images/phpmailer.gif'); // attachment
$mail->AddAttachment('images/phpmailer_mini.gif'); // attachment
$mail->Send();
echo "Message Sent OK<P></P>\n";
} catch (phpmailerException $e) {
echo $e->errorMessage(); //Pretty error messages from PHPMailer
} catch (Exception $e) {
echo $e->getMessage(); //Boring error messages from anything else!
}
AddAttachment将文件从您的服务器。
如何从HTML表单上传文件可以是found here。发送邮件后,您可以从服务器上删除(unlink)该文件。
PHP manual can help you更好地低于和上传文件。
所有你想要做的事情都很容易实现,但是解释的时间比做的要长:)但是,我给你的所有链接都有你需要的一切。如果您有具体问题,请告诉我。
对于上面提到的其他解决方案之一,您可能会问得更多。让这些工作比试图推出自己的解决方案要容易得多。事实是文件附件并不那么简单。 – Cfreak 2010-07-10 21:08:35