จากบทความ
Yii ส่งเมล ด้วย php lib swiftmailer ซึ่งเป็น extensions สำหรับส่งเมล SMTP
ถ้าต้องการใช้ SMTP ของ Gmail เป็นตัวช่วยส่งเมลแทน function mail() ของ php หรือ แทน SMTP ของ Mail Server ของเราเอง
วิธีคือ ให้สมัครสามชิก gmail.com เพื่อสร้าง username และ password สำหรับใช้งาน smtp ของ gmail หรือจะใช้ account ของ Google App ก็ได้ เมื่อได้ username และ password ให้ตั้งค่าตามนี้
'mail' => array(
'class' => 'application.extensions.yii-mail.YiiMail',
'transportType' => 'smtp', // change to 'php' when running in real domain.
'viewPath' => 'application.views.mail',
'logging' => true,
'dryRun' => false,
'transportOptions' => array(
'host' => 'smtp.gmail.com', //if not work, try smtp.googlemail.com
'username' => '[email protected]',
'password' => 'test',
'port' => '465',
'encryption' => 'tls',
),
),
),โดยที่ host คือ mailserver ของ Gmail ให้เราใส่ smtp.gmail.com ได้แลย
ส่วน port ก็คือ 465
อย่าลืมก่อนที่จะใช้ smtp ของ Gmail ได้นั้น Server เราต้องมี OpenSSL ดูข้อมูลเพิ่มเติมได้ที่
ส่งเมลล์ hotmail Script php send mail ไม่ใช้เข้า Junk Mail ด้วย SMTP ของ Gmail