[英]Missing attachement in mail sent through Mime / SMTP Gmail Server (PHP, PEAR)
[英]php pear email works with gmail smtp, but no emails get sent with local server
我剛剛升級到ubuntu 12.04,安裝了pear,mail和mail_mime。 我在下面使用示例代碼。 它曾經可以工作,但是我不確定是否在php.ini中進行了一些更改。 自上次設置以來已經有一段時間了。 我使用gmail smtp服務器進行了測試,並且一切正常。
<?
include('Mail.php');
include('Mail/mime.php');
// Constructing the email
$sender = "Leigh <leigh@no_spam.net>"; // Your name and email address
$recipient = "Leigh <leigh@no_spam.net>"; // The Recipients name and email address
$subject = "Test Email"; // Subject for the email
$text = 'This is a text message.'; // Text version of the email
$html = '<html><body><p>This is a html message</p></body></html>'; // HTML version of the email
$crlf = "\n";
$headers = array(
'From' => $sender,
'Return-Path' => $sender,
'Subject' => $subject
);
// Creating the Mime message
$mime = new Mail_mime($crlf);
// Setting the body of the email
$mime->setTXTBody($text);
$mime->setHTMLBody($html);
$body = $mime->get();
$headers = $mime->headers($headers);
// Sending the email
$mail =& Mail::factory('mail');
$mail->send($recipient, $headers, $body);
?>
我有什么想念的嗎? 我應該在php.ini中更改sendmail_path嗎? 或者其他的東西?
您可以從apache check的error.log文件中找到該錯誤
sudo tail -f /var/log/apapche2/error.log
在這里您可以找到發送郵件的錯誤
sudo apt-get install php-pear
sudo pear install mail
sudo pear install Net_SMTP
sudo pear install Auth_SASL
sudo pear install mail_mime
任何嘗試立即發送郵件:)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.