Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Email With Rails 3 and Heroku Net::SMTPSyntaxError: 501 Syntax error

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 => '[email protected]', :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.

like image 320
LennonR Avatar asked May 13 '11 23:05

LennonR


1 Answers

Your from is invalid. Try from '[email protected]' instead.

like image 70
Roman Avatar answered Oct 04 '22 19:10

Roman