Avoid smtp server syntax error by replacing brackets with parentheses in from_name #139

Closed
wants to merge 1 commit into
from

Projects

None yet

2 participants

@milkfarm

When ActionMailer is configured to use either Gmail or Mailgun as an smtp server, the server returns a syntax error and the email fails to be sent. Replacing the brackets in the refinery.inquiries.config.from_name translation with parentheses solves the problem.

Gmail error in production log:

Rendered ~/.rvm/gems/ruby-1.9.3-p194@refinery/gems/refinerycms-inquiries-2.1.0/app/views/refinery/inquiries/inquiry_mailer/confirmation.text.erb (15.5ms)

Sent mail to test@domain.com (227.2ms)
There was an error delivering an inquiry confirmation:
555 5.5.2 Syntax error. q2sm11379636qer.22 - gsmtp  

Mailgun error in production log:

Rendered ~/.rvm/gems/ruby-1.9.3-p194@refinery/gems/refinerycms-inquiries-2.1.0/app/views/refinery/inquiries/inquiry_mailer/confirmation.text.erb (1.3ms)

Sent mail to test@domain.com (374.9ms)
There was an error delivering an inquiry confirmation:
501 Syntax error
@milkfarm milkfarm Avoid smtp server syntax error by replacing brackets with parentheses
When ActionMailer is configured to use either Gmail or Mailgun as an
smtp server, the server returns a syntax error and the email fails to
be sent. Replacing the brackets in 'refinery.inquiries.config.from_name'
with parentheses solves the problem.
b55dc97
@ugisozols
Member

Interesting. Is there a link to some doc explaining this? We could link to it from here for the future reference.

@milkfarm

I've spent a short time googling it to no success. I've also done some more testing with Gmail. Based on the fact that one can send mail through the Gmail web UI to an address with brackets (e.g. Joe [domain] joe@domain.com) lead me to believe that the syntax error can be resolved in other ways. It is the case. Wrapping the name section of the email address in quotes also averts the error:

:from      => '"' + ::I18n.t('from_name',
                  :scope => 'refinery.inquiries.config',
                  :site_name => Refinery::Core.site_name,
                  :name => @inquiry.name) + '"' + " <#{Refinery::Inquiries.from_name}@#{request.domain}>",

With a bit of tweaking, I think this is the better solution. Here's a StackOverflow issue to back it up.

@ugisozols
Member

Earlier today I merged #136 which adds quotes around name so I guess we can close this :)

@milkfarm milkfarm closed this Jan 21, 2014
@milkfarm milkfarm deleted the milkfarm:replace-brackets branch Jan 21, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment