Mailer模块
**Rails 自带邮件发送功能**
Models
1.创建迁移文件:
rails g mailer UserMailer test_send_mail
development.rb配置
config.action_mailer.perform_caching = false
config.action_mailer.perform_deliveries = true
config.action_mailer.raise_delivery_errors = true # 发送邮件报错 是否抛出异常
config.action_mailer.delivery_method = :smtp # 发送方法
config.action_mailer.smtp_settings = {
address: 'smtp.qq.com', # 邮件服务器
port: 465, # 邮件服务器发送邮件端口
ssl: true, # 采用ssl方法链接
user_name: 'XXXXXXXX@qq.com', # 发送邮件人的账号
password: 'XXXXXXXXXX', # 发送邮件人的授权号
authentication: 'plain',
enable_starttls_auto: true,
}
参考文档
采用ssl链接邮件服务器发送邮件(先登录qq邮箱)
邮件配置信息介绍
官方Mailer模块
总结
1.主要介绍发送邮件配置(发送写法参考文档)
2.该配置用于development环境,production暂为测试
3. 参考kevin_dev_local_v7_minnan(develpoment发送异常,production正常)