使用php和gmail發送電子郵件的最佳方式是什麼?使用php和gmail發送電子郵件的最佳方式是什麼?
我發現下面的鏈接日:
但下載後PHPMailer的形成是網站,我無法找到class.phpmailer.php!
你會告訴我一種發送郵件(Gmail服務器和PHP LAN)的方式?
另一個問題是我的Gmail帳戶設置在smtp /可以嗎?
問候
使用php和gmail發送電子郵件的最佳方式是什麼?使用php和gmail發送電子郵件的最佳方式是什麼?
我發現下面的鏈接日:
但下載後PHPMailer的形成是網站,我無法找到class.phpmailer.php!
你會告訴我一種發送郵件(Gmail服務器和PHP LAN)的方式?
另一個問題是我的Gmail帳戶設置在smtp /可以嗎?
問候
我建議你使用SwiftMailer其SmtpTransport,在那裏你指定smtp.gmail.com作爲SMTP服務器,並指定使用SSL。
$transport = Swift_SmtpTransport::newInstance('smtp.gmail.com')
->setPort(465)
->setEncryption('ssl')
->setUsername('[email protected]')
->setPassword('YOUR_SECRET_PWD');
...
編輯, 的要求 - 這裏有一個完整的例子(雖然未經測試):
<?php
require_once "lib/swift_required.php";
$transport = Swift_SmtpTransport::newInstance('smtp.gmail.com')
->setPort(465)
->setEncryption('ssl')
->setUsername('[email protected]')
->setPassword('YOUR_SECRET_PWD');
$mailer = Swift_Mailer::newInstance($transport);
$htmlBody = '<html><body><h1>HTML-mail example!</h1><p>Contents</p></body></html>';
$plainBody = 'Looks like you cannot read HTML-emails? This is alternative content only for you.';
$message = Swift_Message::newInstance('This is the subject of the e-mail')
->setFrom(array('[email protected]' => 'You Name'))
->setTo(array('[email protected]' => 'Your Friends Name'))
->setBody($plainBody)
->addPart($htmlBody, 'text/html');
$mailer->send($message);
也許有Zend框架包含免費的主機?
所以,你可以使用Zend的郵件: http://framework.zend.com/manual/1.11/en/zend.mail.introduction.html
u能告訴我一個完整的代碼,而無需使用PHPMailer的所有功能,如SSL /端口/ HTML的身體... – LostLord 2011-01-30 21:13:30
可能想SO問題在結賬類似:http://stackoverflow.com/questions/36079/php-mail-using-gmail – used2could 2011-01-30 21:16:35