I've tried everything I can think of to get emails to send with Rails 4.1.6 (local development) but nothing is working. Using Postmark I have the following in my development.rb and application.rb:
我已经尝试了所有我能想到的东西,通过Rails 4.1.6(本地开发)发送电子邮件,但没有任何工作。使用Postmark我在development.rb和application.rb中有以下内容:
config.action_mailer.default_url_options = { host: 'localhost', port: 3000 }
config.action_mailer.delivery_method = :postmark
config.action_mailer.postmark_settings = { :api_key => API_KEY }
config.action_mailer.perform_deliveries = true
and for GMAIL I tried:
我为GMAIL尝试过:
config.action_mailer.default_url_options = { host: 'localhost', port: 3000 }
config.action_mailer.perform_deliveries = true
config.action_mailer.delivery_method = :smtp
config.action_mailer.smtp_settings = {
address: 'smtp.gmail.com',
port: 587,
domain: 'gmail.com',
user_name: 'my_email',
password: 'my_password',
authentication: 'plain',
enable_starttls_auto: true }
My Mailer class looks like so:
我的Mailer类看起来像这样:
class BusinessMailer < ActionMailer::Base
default from: "my_email@email.com"
def claim_business business
mail(
:subject => 'hello',
:to => 'myemail@email.com',
:from => 'myemail@email.com',
:html_body => '<strong>Hello John Doe<strong>',
:track_opens => 'true'
)
end
end
And lastly I'm sending the email via: BusinessMailer.claim_business @business
最后我通过以下方式发送电子邮件:BusinessMailer.claim_business @business
When I trigger the claim_business
method I see BusinessMailer#claim_business: processed outbound mail in 14.1ms
in my console with no error messages. Can anyone tell me what I'm missing here?
当我触发claim_business方法时,我看到BusinessMailer#claim_business:在我的控制台中在14.1ms内处理出站邮件,没有错误消息。谁能告诉我我在这里缺少什么?
1 个解决方案
#1
16
You're missing deliver
method to eventually send the email. Try:
您缺少交付方法以最终发送电子邮件。尝试:
BusinessMailer.claim_business(@business).deliver
#1
16
You're missing deliver
method to eventually send the email. Try:
您缺少交付方法以最终发送电子邮件。尝试:
BusinessMailer.claim_business(@business).deliver