我正在尝试通过我的应用中的rake任务发送电子邮件。我的邮件程序与服务器完美协作,但是在执行rake任务时,它什么也不做。
这是我的耙任务:
namespace :booking do
desc "Send an email about a upcoming job to the clients"
task :send_email_upcoming_job_forty_eight => :environment do
begin
puts("Im sending email forty eight with the class #{AdminMailer}")
AdminMailer.notify_client_accepted("fmaymone@gmail.com")
puts("Finished")
rescue StandardError => e
puts e
end
end
end
这是我的AdminMailer方法:
def notify_client_accepted(email)
puts("Sending client_acepted #{email}")
data = JSON.parse('{
"personalizations": [
{
"to": [
{
"email": "'+email+'"
}
],
"dynamic_template_data": {
"subject": "Testing Templates",
"login_url": "'+root_url+'"
}
}
],
"from": {
"email": "info@sculp.com"
},
"content": [
{
"type": "text/plain",
"value": "Admin Mailer"
}
],
"template_id": "d-e02e093acf424728b191b776daeecec8"
}')
puts data
self.send_sendgrid_email(data)
end
当我跑步时:耙预订:send_email_upcoming_job_forty_eight
我来自控制台:
Im sending email forty eight with the class AdminMailer
Finished
但是电子邮件永远不会到达。 AdminMailer arent内部的“ puts”也打印在控制台上
任何想法为何? (请记住。AdminMailer在我的应用程序中运行良好。rake任务不是)