私はあなたがSMTPサーバとしてsmtp.gmail.comを指定し、SSLを使用するように指定してSmtpTransport、とSwiftMailerを使用することをお勧め。
Example:
$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);
Uは、SSL /ポート/ htmlの体としてのすべての機能をphpmailerのを使用せずに、私の完全なコードを表示することができます... – LostLord
はで同様のSO質問をチェックアウトすることもできます:http://stackoverflow.com/questions/36079/php-mail-using-gmail – used2could