ruby-on-rails – Rails cron不发送电子邮件
发布时间:2020-12-17 02:44:43 所属栏目:百科 来源:网络整理
导读:我正在使用随时随地拥有rails cron作业发送电子邮件.一切似乎工作得很好,我的cron.log或我的production.log文件没有错误,但我从来没有收到过电子邮件.我已经检查过电子邮件地址也是正确的. 任何帮助表示赞赏. production.log文件包含以下内容: Connecting t
我正在使用随时随地拥有rails cron作业发送电子邮件.一切似乎工作得很好,我的cron.log或我的production.log文件没有错误,但我从来没有收到过电子邮件.我已经检查过电子邮件地址也是正确的.
任何帮助表示赞赏. production.log文件包含以下内容: Connecting to database specified by database.yml Rendered email_mailer/send_birthday_reminders.html.erb (5.3ms) Sent mail to tomcaflisch@gmail.com (409ms) 这是我的每当gem schedule.rb文件 set :output,"#{path}/log/cron.log" every :hour do runner "BirthdayRemindersController.send_birthday_email_reminders" end birthday_reminders_controller.rb class BirthdayRemindersController < ApplicationController # cron job that sends birthday reminders def self.send_birthday_email_reminders users = User.all email_addresses = [] users.each_with_index do |user,i| if user.user_details.birthday_reminders == true email_addresses[i] = get_primary_email(user) end end p "email_addresses to send to:" p email_addresses users.each do |user| p "this user is" p user.user_details.full_name if user.user_details.birthday.try(:strftime,"%m") == Date.today.strftime("%m") && user.user_details.birthday.try(:strftime,"%d") == Date.today.strftime("%d") p "reminder sent" EmailMailer.send_birthday_reminders(user,email_addresses).deliver end end end end email_mailer.rb片段 class EmailMailer < ActionMailer::Base include ApplicationHelper default :from => ""FamNFo" <no-reply@mysite.com>" def send_birthday_reminders(birthday_person,email_addresses) p "we in send_birthday_reminders mailer" p email_addresses @birthday_person = birthday_person mail(:subject => "Birthday Reminder For The Caflisch Family",:to => email_addresses,:reply_to => email_addresses) end end capistrano的deploy.rb包含了这个 # needed for the 'whenever' gem set(:whenever_command) { "RAILS_ENV=#{rails_env} bundle exec whenever"} require "whenever/capistrano" 解决方法
检查垃圾邮件文件夹.要确保电子邮件不会在那里结束,请在每封电子邮件中添加“取消订阅”链接.
(编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |