Rails 3, :from, Net::SMTPSyntaxError (502 5.5.1 Unrecognized command

2k Views Asked by At

I'm running into this error "Net::SMTPSyntaxError (502 5.5.1 Unrecognized command"

I have this code working:

class Notifier < ActionMailer::Base
default :from => "[email protected]"

def comment_updated(comment, user)
  @comment = comment
  @user = user
  mail(:to => user.email,
  :subject => "[JS] #{comment.job.subject_name} -               #    {comment.job.subject_name}")

  end
end

But the code below throws this error "Net::SMTPSyntaxError (502 5.5.1 Unrecognized command":

class Notifier < ActionMailer::Base
default :from => "[email protected]"

def comment_updated(comment, user)
  @comment = comment
  @user = user
  mail(:to => user.email,
  :subject => "[JS] #{comment.job.subject_name} -               #{comment.job.subject_name}",
   :from => "jSearch 
   <comment+#{comment.job_id}@mysite.tv>") do  |format|
    format.text
    format.html
    end
  end
end

I would like to use the Cloudmailin service to process my incoming emails, so I would like to have a :from address when users click reply.

Any idea why this code with the extra :from wouldn't work?

1

There are 1 best solutions below

0
On

I can remember this being an issue that I also experienced before. I think there's a bug that prevents you specifying a full from address. From appears to only accept a valid email address. comment+#{comment.job_id}@mysite.tv will work but for some reason jSearch <comment+#{comment.job_id}@mysite.tv> does not. Unfortunately I can't reproduce this now.

The error message that you're seeing is the SMTP server stating that it doesn't understand the format of your command (I'm guessing as it passed the MAIL FROM: jSearch <[email protected]>. Unfortunately my only suggestion right now is to remove the name part of the from address.