rails 发送电子邮件(ActionMailer)
来源:互联网 发布:淘宝阴氏埙哪里买 编辑:程序博客网 时间:2024/05/08 04:07
ActionMailer 在后台发送邮件
1.创建mailer
- rails g mailer UserMailer
2.编辑app/mailer/user_mailer
- class UserMailer < ActionMailer::Base
- default from: "xxxxxxxx@163.com"
- # def confirm(email)
- # subject "激活'我的生活'账户"
- # recipients email
- # from 'xxxxxxxx@163.com'
- # sent_on Time.now
- # body "欢迎加入‘我的生活’,我们致力于更加方便的生活,请点击激活账户"
- # end
- # def welcome_email(user)
- # @user = user
- # @url = 'http://example.com/login'
- # mail(to: 'xxxxxxxx@163.com', subject: 'Welcome to My Awesome Site')
- # end
- def send_mail(params = {})
- @url = 'http://example.com/login'
- mail( :subject => 'abcAAAAAAAASDFADSFADSFADSFDASFASDF',
- :to => "xxxxxxxx@163.com",
- :from => 'xxxxxxxx@163.com',
- :date => Time.now
- )
- end
- end
3.配置action mailer了,由于国内的gmail连接老出现问题,所以这里就介绍163 environments/development.rb
- ActionMailer::Base.delivery_method = :smtp
- config.action_mailer.perform_deliveries = true
- config.action_mailer.raise_delivery_errors = true
- config.action_mailer.default :charset => "utf-8"
- config.action_mailer.default_url_options = { :host => 'localhost:3000' }
- ActionMailer::Base.smtp_settings = {
- :address => "smtp.163.com",
- :port => 25,
- :domain => "163.com",
- :authentication => :login,
- :user_name => "mxbeijingmi@163.com",
- :password => "menxu0725"
- }
4.发送邮件
- UserMailer.send_mail(nil).deliver
5.官方文档: http://guides.rubyonrails.org/action_mailer_basics.html
0 0
- rails 发送电子邮件(ActionMailer)
- rails 发送电子邮件(ActionMailer)
- rails 3使用ActionMailer通过163发送邮件
- rails 2.3.2 发送电子邮件的配置
- rails ActionMailer 使用SendCloud的配置
- ROR中使用ActionMailer发送邮件
- 使用ActionMailer 的 STMP方式发送邮件
- 发送电子邮件
- 发送电子邮件
- 发送电子邮件
- 发送电子邮件
- 发送电子邮件
- 发送电子邮件
- 发送电子邮件
- 电子邮件发送
- 发送电子邮件
- 发送电子邮件
- 发送电子邮件
- [iOS进阶]iOS缓存机制详解
- Ruby 元编程 类的真相
- 2 - 1.1 = 0.8999999999999999
- 用USB 安装linux
- 字符串转化为艺术字图片
- rails 发送电子邮件(ActionMailer)
- CUICatalog: Invalid asset name supplied: (null)、Unknown CGRect
- 省赛选拔赛总结
- LeetCode的easy题集合(C++实现)二
- 工业相机的选择方法
- VC实现实用文件按指定名字批量改名
- 一个复杂子查询SQL优化
- Devise 给项目添加权限验证系统
- 【ExtJs】与后台数据库交互的带分页表格组件grid的查询