收到Paypal付款后,通过电子邮件发送文件

时间:2014-03-28 10:27:34

标签: php paypal

收到Paypal付款后,有没有办法在电子邮件中发送文件?任何教程,以显示如何做到这一点?任何帮助将不胜感激。

2 个答案:

答案 0 :(得分:0)

如果我收到PayPal的确认,我会使用SwiftMailer / attahching files

答案 1 :(得分:-1)

使用PHP内置的mail函数可以轻松发送电子邮件。但是,发送附件是另一回事。

我使用第三方库,例如phpMailer

E.g。发送带附件的电子邮件:

require_once('path/to/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!";
}