简体   繁体   English

如何配置我的服务器以从Ruby on Rails发送电子邮件

[英]How configure my server to send emails from Ruby on Rails

I am using the server that comes with Rails and I need to configure it to send emails to recipients such as juan@gmail.com and pepe@hotmail.com. 我正在使用Rails附带的服务器,我需要对其进行配置以将电子邮件发送给诸如juan@gmail.com和pepe@hotmail.com的收件人。

Do I need to use my Gmail account or install a local SMTP service. 我是否需要使用我的Gmail帐户或安装本地SMTP服务。 I'm a newbie in ruby on rails 我是红宝石的新手

I am executing this using Mailers. 我正在使用Mailers执行此操作。

An example that I saw on internet is below. 我在互联网上看到的示例如下。

ActionMailer::Base.smtp_settings = {
  :user_name => 'your_sendgrid_username',
  :password => 'your_sendgrid_password',
  :domain => 'yourdomain.com',
  :address => 'smtp.sendgrid.net',
  :port => 587,
  :authentication => :plain,
  :enable_starttls_auto => true
} 

To send mail from local put the code below in you config/application.rb 要从本地发送邮件,请将以下代码放在config / application.rb中

config.action_mailer.delivery_method = :smtp
    config.action_mailer.smtp_settings = {
      :address              => "smtp.gmail.com",
      :port                 => 587,
      :domain               => 'gmail.com',
      :user_name            => 'your_email_id',
      :password             => 'password',
      :authentication       => 'plain',
      :enable_starttls_auto => true  }

Add the below line in application.rb file... 在application.rb文件中添加以下行...

config.action_mailer.default_url_options = { :host => 'localhost', :port => 3000 }

To send mail from local put the code below in you config/environments/devleopment.rb 要从本地发送邮件,请将下面的代码放在config / environments / devleopment.rb中

config.action_mailer.delivery_method = :smtp
config.action_mailer.smtp_settings = {
  address:              'smtp.gmail.com',
  port:                 587,
  domain:               'example.com',
  user_name:            '<your gmail username>',
  password:             '<and its password>',
  authentication:       'plain',
  enable_starttls_auto: true  }

REF : http://guides.rubyonrails.org/action_mailer_basics.html 参考: http : //guides.rubyonrails.org/action_mailer_basics.html

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何配置Rails以发送500错误的电子邮件? - How do I configure Rails to send emails on 500 error? 如何从Rails应用程序上的ruby接收电子邮件 - how to receive emails from a ruby on rails app 如何为XAMP服务器配置Ruby ob Rails? - How to configure Ruby ob Rails for XAMP server? 如何使用Actionmailer / Ruby on Rails发送具有多个动态smtp的电子邮件 - How to send emails with multiple, dynamic smtp using Actionmailer/Ruby on Rails 如何在Ruby on Rails中发送带有回执的电子邮件? - How to send emails with return-receipts in Ruby on Rails? Google为什么拒绝我的Ruby on Rails应用中的电子邮件? - Why is google rejecting emails from my Ruby on Rails app? Ruby on Rails,发送所有外发电子邮件的副本 - Ruby on Rails, Send a copy of all outgoing emails Ruby on Rails,同时发送多封电子邮件 - Ruby on Rails, send multiple emails simultaneously 在Rails中,如何使用mdaemon邮件服务器通过Action Mailer发送电子邮件? - In rails, How to send emails with action mailer using mdaemon mail server? 如何为Ruby on Rails配置Devise以将电子邮件和密码存储在除用户模型之外的其他位置? - How can I configure Devise for Ruby on Rails to store the emails and passwords somewhere other than in the user model?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM