Getting at ":to is required" error even though it's set in my default settings under config/initializers

23 views
Skip to first unread message

Sungho Yoo

unread,
Nov 27, 2013, 4:44:57 PM11/27/13
to pon...@googlegroups.com
This used to work fine but has recently acted up when I tested it, which makes me wonder if it's a bug. 

Been googling the problem for 2 hours and found nothing similar to this issue. 

My model is:

class Inquiry 
  extend ActiveModel::Naming
  include ActiveModel::Conversion
  include ActiveModel::Validations
  include ActionView::Helpers::TextHelper
  
  attr_accessor :name, :email, :residence, :service

  validates :residence, 
            :presence => true
  
  validates :name, 
            :presence => true
  
  validates :email,
            :format => { :with => /\b[A-Z0-9._%a-z\-]+@(?:[A-Z0-9a-z\-]+\.)+[A-Za-z]{2,4}\z/ },
            :presence => true

  validates :service,
            :presence => true

  def initialize(attributes = {})
    attributes.each do |name, value|
      send("#{name}=", value)
    end
  end

  def deliver
    return false unless valid?
    Pony.mail({
      :from => %("#{name}" <#{email}>),
      :reply_to => "em...@gmail.com",
      :subject => "subject",
      :body => %("#{residence}" "#{name}" <#{email}> "#{service}")
    })
  end
      
  def persisted?
    false
  end
end

My initializer is:

Pony.options = {
  :to => 'em...@gmail.com',
  :via => :smtp,
  :via_options => {
    :address              => 'smtp.gmail.com',
    :port                 => '587',
    :enable_starttls_auto => true,
    :user_name            => ENV["GMAIL_USERNAME"],
    :password             => ENV["GMAIL_PASSWORD"],
    :authentication       => :login, # :plain, :login, :cram_md5, no auth by default
    :domain               => "localhost.localdomain" # the HELO domain provided by the client to the server
  }
}

Any idea what I'm doing wrong here?

-Sungho

Ben Prew

unread,
Nov 28, 2013, 2:30:08 AM11/28/13
to pon...@googlegroups.com
Sungho,

What do you get if before you call mail, you add:

puts Pony.options.inspect

That should show you the options class variable.  Perhaps the initializer isn't getting called?


--
 
---
You received this message because you are subscribed to the Google Groups "Ponyrb" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ponyrb+un...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Reply all
Reply to author
Forward
0 new messages