2012-12-12 10 views
12

Wer hat Glück, ActionMailer so zu konfigurieren, dass er E-Mails über ein Zoho-Konto sendet?Rails ActionMailer-Konfiguration für Zoho

Das sind meine Einstellungen:

ActionMailer::Base.smtp_settings = { 
    :address    => "smtp.zoho.com", 
    :port     => 465, 
    :domain    => 'example.com', 
    :user_name   => '[email protected]', 
    :password    => 'n0tmypa$$w0rd', 
    :authentication  => :login 
} 

jedoch mal Aufruf .deliver aus:

irb(main):001:0> AdminMailer.signup_notification('asfd').deliver 
Timeout::Error: Timeout::Error 
     from C:/Ruby193/lib/ruby/1.9.1/net/protocol.rb:146:in `rescue in rbuf_fill' 
     from C:/Ruby193/lib/ruby/1.9.1/net/protocol.rb:140:in `rbuf_fill' 
     from C:/Ruby193/lib/ruby/1.9.1/net/protocol.rb:122:in `readuntil' 
     from C:/Ruby193/lib/ruby/1.9.1/net/protocol.rb:132:in `readline' 
     from C:/Ruby193/lib/ruby/1.9.1/net/smtp.rb:929:in `recv_response' 
     from C:/Ruby193/lib/ruby/1.9.1/net/smtp.rb:552:in `block in do_start' 
     from C:/Ruby193/lib/ruby/1.9.1/net/smtp.rb:939:in `critical' 
     from C:/Ruby193/lib/ruby/1.9.1/net/smtp.rb:552:in `do_start' 
     from C:/Ruby193/lib/ruby/1.9.1/net/smtp.rb:519:in `start' 
     from C:/Ruby193/lib/ruby/gems/1.9.1/gems/mail-2.4.4/lib/mail/network/delivery_methods/smtp.rb:144:in `deliver!' 

Die help docs sagen Port 465 und SSL-Authentifizierung zu verwenden. Ich habe es mit und ohne :enable_starttls_auto => true versucht aber es kommt immernoch mal raus.

Insbesondere die docs die folgenden Einstellungen an:

>  Email Address: [email protected] 
>  User Name format: [email protected] 
>  Secure Connection (SSL) Yes 
>  Outgoing Mail Server Name: smtp.zoho.com 
>  Outgoing Port No.: 465 
>  Outgoing Mail Server requires authentication: Yes 

Irgendwelche Ideen?

p.s. Ich habe Outlook konfiguriert, um die Einstellungen in der help docs verwenden und ausgehende E-Mail funktioniert gut. telnet zu smtp.zoho.com 465 verbindet auch.

+0

werden Sie von Ihrem lokalen Host versuchen ??? – Jean

+0

Ich bin, obwohl der SMTP-Server natürlich remote ist (zoho.com). Wäre das wichtig? E-Mail-Client (Outlook) mit den gleichen Einstellungen ist auch auf dem gleichen localhost. – lambinator

+0

Nicht sicher, ob Sie Outlook verwenden möchten, scheint Microsoft ausgehende Mail von Anwendungen nicht geduldet - auch für notwendige Dinge wie E-Mail-Bestätigungen. – Noz

Antwort

29
# Action Mailer 
ActionMailer::Base.delivery_method = :smtp 
ActionMailer::Base.smtp_settings = {    
    :address    => "smtp.zoho.com", 
    :port     => 465,     
    :user_name   => '[email protected]', 
    :password    => 'password',   
    :authentication  => :login, 
    :ssl     => true, 
    :tls     => true, 
    :enable_starttls_auto => true  
} 

Das hat für mich funktioniert. Ihre Einstellungen können in Ordnung sein, einige lokale Netzwerke blockieren diese Arten von Paketen. Ich musste es über mein 3G-Netzwerk testen.

+1

hat die delivery_method weggelassen. : S – lambinator

+0

Hat jemand diese Einstellungen mit Spree probiert? –

+1

Mein Tag gerettet! :) – vellotis

0

Ich bin mir nicht sicher, ob Zoho ihre Sicherheitseinstellungen geändert haben, aber @Tyrel Richey ‚s akzeptierte Antwort für mich nicht funktioniert hat. Jedoch folgendes tut:

/config/initializers/action_mailer.rb ..

 
# ActionMailer email configuration 
ActionMailer::Base.delivery_method = :smtp 
ActionMailer::Base.smtp_settings = { 
    :address    => ENV['SMTP_ADDRESS'], 
    :port     => ENV['SMTP_PORT'], 
    :domain    => ENV['SMTP_DOMAIN'], 
    :user_name   => ENV['SMTP_USERNAME'], 
    :password    => ENV['SMTP_PASSWORD'], 
    :authentication  => :login, 
    :enable_starttls_auto => true 
} 

Wo ..
:address = smtp.zoho.com
:port = 587
:domain ist localhost in der Entwicklung, und die Live-URL in der Produktion (zB example.com)

+0

dein port sollte 465 sein.set ssl und tls auf true setzen –

+0

Es hat @DankeXie funktioniert, Danke :) –

3

FYI:

Angenommen, Ihre Domain lautet abc.com.
Nehmen wir an, Sie haben "Standard von" auf Ihrem Mailer mit einer anderen Domain, z.

default from: "\"Elephant\" <[email protected]>" 

Diese wird nicht funktionieren, wenn Sie ‚von Standard‘ Ihre ändern, um die gleiche Domain auf Ihrem zoho Konto.
So

default from: "\"Elephant\" <[email protected]>" 

arbeiten.

0

Ich habe Mail mit Rails 4.2.3 Senden wie so ...

# config/environments/development.rb 
Rails.application.configure do 
#... 
    config.action_mailer.default_url_options = { host: 'domain' } 
    config.action_mailer.smtp_settings = { address: 'smtp.zoho.com', port: 465, user_name: '[email protected]', password: 'mypassword', authentication: :login, ssl: true } 
end 

Sie dies natürlich auch in der Produktion durch das Hinzufügen dieser zu config/environments/production.rb

verwenden kann ich auch die E-Mail-Adresse eingestellt in config/initializers/devise.rb so kann ich Passwort Reset-Anweisung senden.

config.mailer_sender = '[email protected]' 


Referenzen

0

Diese Einstellungen arbeitete in der Produktion für mich.

Rails.application.routes.default_url_options[:host] = 'eyehawk.io' 
    config.action_mailer.default_url_options = { :host => 'eyehawk.io' } 
    config.action_mailer.perform_caching = false 

    config.action_mailer.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.smtp_settings = { 
     :address    => "smtp.zoho.com", 
     :port     => 587, 
     :domain    => "zoho.com", 
     :user_name   => "[email protected]", 
     :password    => ENV['SMTP_PASSWORD'], 
     :authentication  => :plain, 
     :enable_starttls_auto => true 
    }