Pergunta

As the title says I'm trying to get a simple email working with Heroku and Rails 3. I'm using this Heroku guide: http://devcenter.heroku.com/articles/smtp

Here is my code:

I generated a mailer that looks like this:

class Invite < ActionMailer::Base
  def signup_notification(user)
    recipients "#{user.first_name} <#{user.email}>"
    from       "Test"
    subject    "Please activate your new account"
    sent_on    Time.now
    body       :var => 'testing'
  end
end

I have a view in app/views/invite/signup_notification.rhtml

UPDATE: I see that .rhtml doesn't work with Rails 3 so I just tried .html.erb but I got the same error.

Your account has been created.
Username: 
Password: 
Visit this url to activate your account:

Then in the Heroku console I did this:

user = User.new(:first_name => 'Me', :email => 'me@hotmail.com', :login => 'me', :password => '1234')

and then this:

Invite.deliver_signup_notification(user)

and if get this error:

Net::SMTPSyntaxError: 501 Syntax error
  /user/ruby1.8.7/lib/ruby/1.8/net/smtp.rb:930:in `check_response`
  /user/ruby1.8.7/lib/ruby/1.8/net/smtp.rb:899:in `getok`
  /user/ruby1.8.7/lib/ruby/1.8/net/smtp.rb:828:in `mailfrom`
  /user/ruby1.8.7/lib/ruby/1.8/net/smtp.rb:653:in `sendmail`

Thanks for any ideas.

Foi útil?

Solução

Your from is invalid. Try from 'test@example.com' instead.

Outras dicas

If you want to show custom string in from then you can use something like

from  "Test <info@domain.com>"

and when you send email title would be Test

The Heroku guide is for Rails < 3.0. Use the Rails guide for 3.0.

Net::SMTPSyntaxError 501 error is thrown if you have bad sender address. Sender address should be an email address. Any fake email will also do. like: abc@fakemail.com

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top