marios
marios

Reputation: 153

how to receive emails from a ruby on rails app

i am in dead end! i am trying to make an app to receive emails on hotmail! i created a method and i am getting an error and no email receiving..

in my method:

class Recivemail < ActiveRecord::Base
  attr_accessible :content, :from, :subject

 def sendmail(content,from,subject)
    subject = 'subject'
    recipients = "[email protected]"
    from = 'from'
    sent_on = Time.now
  end 
end

in config>enviroments>development.rb

 config.action_mailer.delivery_method = :smtp
  config.action_mailer.smtp_settings ={
    :enable_starttls_auto => true,
    :address => 'smtp.hotmail.com',
    :port => 587,
    :authentication => :plain,
    :domain => 'localhost:3000',
    :user_name => '[email protected]',
    :password => 'mypass'

  }

in views>recivemails>show

<%[email protected](@recivemail.from,@recivemail.subject,@recivemail.content)%>

everything seems to working correct except that i am not getting any email any ideas??

Upvotes: 0

Views: 221

Answers (1)

jdl
jdl

Reputation: 17790

@recivemail.send(@recivemail.from,@recivemail.subject,@recivemail.content)

The send method in Ruby means "send a message to this object" (as-in call the method that is named by the first parameter to send). What you're doing here is trying call a method named by the value of @recivemail.from to the object @recivemail.

http://ruby-doc.org/core-1.9.3/Object.html#method-i-send

In your code, the method is named sendmail not send anyway.

(I would not put this into a view either, but that seems to be the least of your troubles right now.)

As for your original question about receiving emails in general, start with this article. It was written several years ago, but should give you some ideas.

Upvotes: 3

Related Questions