1
任何人都可以幫我?我試圖發送附件的電子郵件發送電子郵件,但電子郵件發送編碼格式我認爲問題是與頭部可以任何一個給我的工作代碼..有很多現成的代碼在網上我試過他們沒有所有的人,但工作關於電子郵件附件在php
任何人都可以幫我?我試圖發送附件的電子郵件發送電子郵件,但電子郵件發送編碼格式我認爲問題是與頭部可以任何一個給我的工作代碼..有很多現成的代碼在網上我試過他們沒有所有的人,但工作關於電子郵件附件在php
您可以使用PHPMailer的http://code.google.com/a/apache-extras.org/p/phpmailer/
$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>\n";
} catch (phpmailerException $e) {
echo $e->errorMessage(); //Pretty error messages from PHPMailer
} catch (Exception $e) {
echo $e->getMessage(); //Boring error messages from anything else!
}
感謝
:)
嘗試使用一些好的庫,如phpmailer ... – 2012-03-29 13:57:49
把一些代碼,如果你需要我們找到一個解決方案... ... – 2012-03-29 13:58:54