CI 发送邮件比想象中的还要简单,看过API和视频教程之后,很快就能上手,只要添加一个controller就能发送邮件,前提是你配置好邮件服务器,测试码如下(Controller):
后来发送失败,debugger显示邮件服务器配置问题,于是我配置了XAMPP的邮件服务器,php.ini的配置如下:
SMTP = smtp.gmail.com
smtp_port = 465
sendmail_from = example@gmail.com
sendmail_path = "/"D:/xampp/sendmail/sendmail.exe/" -t"
当然这是win32下的操作,除此之外还有sendemail.ini,按照里面给的example来配置就可以了,示范如下:
# Example for a user configuration file
# Set default values for all following accounts.
defaults
logfile "D:/xampp/sendmail/sendmail.log"
# Mercury
account Mercury
host localhost
from postmaster@localhost
auth off
# A freemail service example
account ddjohn
tls on
tls_certcheck off
host smtp.gmail.com
from example@gmail.com
auth on
user example@gmail.com
password yourpassword
# Set a default account
account default : ddjohn