# How to avoid (Net::SMTPFatalError) "555 5.5.2 Syntax error

**URL:** <https://www.ruby-forum.com/t/how-to-avoid-net-smtpfatalerror-555-5-5-2-syntax-error/166254>\
**Category:** Rails\
**Created:** [April 23, 2009, 8:30am UTC](https://www.ruby-forum.com/t/how-to-avoid-net-smtpfatalerror-555-5-5-2-syntax-error/166254 "2009-04-23T08:30:53Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![santoshturamari](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/ee59a6/32.png) [@santoshturamari](https://www.ruby-forum.com/u/santoshturamari)\
**Post date:** [April 23, 2009, 8:30am UTC](https://www.ruby-forum.com/t/how-to-avoid-net-smtpfatalerror-555-5-5-2-syntax-error/166254/1 "2009-04-23T08:30:53Z")

</div>

Hi all,  
I have written code to send mails through action\_mailer, where in I  
called  
MassNotifier.deliver\_forward\_review\_link(current\_user.profile.display\_name,email,params[:notification][:message],params[:title],params[:designation],params[:company],params[:id],@invitation.invitation\_code)

this method , and in mass\_notifier.rb  
I fave written

def  
forward\_review\_link(sender,recipients,message,title,designation,company,id,code)

return if UnsubscribedEmail.find\_by\_email(recipients)  
@unsubscribe\_code = MailingList.find\_or\_create\_by\_email(recipients)  
if @unsubscribe\_code.code.nil?  
@unsubscribe\_code.code = Digest::SHA1.hexdigest(  
Time.now.to\_s.split(//).sort\_by {rand}.join )  
@unsubscribe\_code.save  
end  
@body[:unsubscribe\_link] = “[click  
here to unsubscribe\</a\>”](http://www.somelink.com/unsubscribe/#{@unsubscribe_code.code})

[ 

```
MassNotifier.delivery_method = :activerecord
@recipients = "#{recipients}"
@from = "#{sender}<removed_email_address@domain.invalid>"
@subject = "Check out the Review on #{company}"
@body[:review_link] = "<a

```

 ](http://www.somelink.com/unsubscribe/#{@unsubscribe_code.code})

[href=‘](http://www.somelink.com/unsubscribe/#{@unsubscribe_code.code})[http://www.somelink.com/company-review-rating/#](http://www.somelink.com/company-review-rating/#){company.downcase.strip.squeeze("  
").gsub(/[^[:alnum:]]/,’-‘).squeeze(“-”).chomp(“-”)}/#{designation.strip.squeeze("  
").gsub(/[^[:alnum:]]/,’-‘).squeeze(“-”).chomp(“-”)}/#{id}’\>clck  
here\</a\>"  
@body[:company\_name] = “#{company}”  
@body[:sender\_name] = “#{sender}”  
content\_type “text/html”  
end

If I submit an email id, It is giving error as  
(Net::SMTPFatalError) “555 5.5.2 Syntax error. d29sm1994943and.38\n”  
How to avoid this error

Please help me its urgent.

---

<div class="post-metadata">

**Author:** ![santoshturamari](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/ee59a6/32.png) [@santoshturamari](https://www.ruby-forum.com/u/santoshturamari)\
**Post date:** [July 31, 2009, 2:26pm UTC](https://www.ruby-forum.com/t/how-to-avoid-net-smtpfatalerror-555-5-5-2-syntax-error/166254/2 "2009-07-31T14:26:36Z")

</div>

Santosh T. wrote:

> ```
> @from = "#{sender}<removed_email_address@domain.invalid>"
> 
> ```

> If I submit an email id, It is giving error as  
> (Net::SMTPFatalError) “555 5.5.2 Syntax error. d29sm1994943and.38\n”

The from line is the problem. The Net::SMTP library was recently changed  
so it adds angle brackets to your sender, so you cannot have any in your  
string. Try this as a workaround:

```
@from = "removed_email_address@domain.invalid"

```

---

<div class="post-metadata">

**Author:** ![santoshturamari](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/ee59a6/32.png) [@santoshturamari](https://www.ruby-forum.com/u/santoshturamari)\
**Post date:** [August 24, 2009, 3:03pm UTC](https://www.ruby-forum.com/t/how-to-avoid-net-smtpfatalerror-555-5-5-2-syntax-error/166254/3 "2009-08-24T15:03:49Z")

</div>

Hi Chris,

the workaround solved the problem, thank you!

Is there another way to display a name with the email address without  
using angle brackets ?

Thanks!

On Jul 31, 2:26 pm, Chris S. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

---

<div class="post-metadata">

**Author:** ![santoshturamari](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/ee59a6/32.png) [@santoshturamari](https://www.ruby-forum.com/u/santoshturamari)\
**Post date:** [August 24, 2009, 5:05pm UTC](https://www.ruby-forum.com/t/how-to-avoid-net-smtpfatalerror-555-5-5-2-syntax-error/166254/4 "2009-08-24T17:05:12Z")

</div>

Francesco C. wrote:

> Hi Chris,
> 
> the workaround solved the problem, thank you!
> 
> Is there another way to display a name with the email address without  
> using angle brackets ?
> 
> Thanks!
> 
> On Jul 31, 2:26ï¿½pm, Chris S. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

Display? Sure. Do anything you want.

But as of Rails 2.3.3, the from email address will get the angle  
brackets added, so it can only contain the address.

Rails 2.3.4 is/was supposed to fix that, and includes tests so it will  
be ensured in future versions.

---

<div class="post-metadata">

**Author:** ![santoshturamari](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/ee59a6/32.png) [@santoshturamari](https://www.ruby-forum.com/u/santoshturamari)\
**Post date:** [August 29, 2009, 12:35am UTC](https://www.ruby-forum.com/t/how-to-avoid-net-smtpfatalerror-555-5-5-2-syntax-error/166254/5 "2009-08-29T00:35:41Z")

</div>

Thank you so much, I had the same problem and it worked.

On Jul 31, 2:26 pm, Chris S. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

---

<div class="post-metadata">

**Author:** ![santoshturamari](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/ee59a6/32.png) [@santoshturamari](https://www.ruby-forum.com/u/santoshturamari)\
**Post date:** [September 1, 2009, 2:25pm UTC](https://www.ruby-forum.com/t/how-to-avoid-net-smtpfatalerror-555-5-5-2-syntax-error/166254/6 "2009-09-01T14:25:54Z")

</div>

Hello all,

I am trying to send email and written code like this:

`
 def matches_for_request( contact, req, matching_offers )
    recipients "#{contact}"
    from "removed_email_address@domain.invalid"
    subject "Matches found for your request"
    sent_on Time.now
```
body[:offers] = matching_offers

```
`

`end
`

I also had put angled brackets in the from address like  
“[removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)”. However, as Chris’s reply suggets I tried  
removing the angled brackets. But, this did not solve my problem. I am  
continuing to get the following error message:

555 5.5.2 Syntax error. 23sm387874pxi.9

Please help.

---

<div class="post-metadata">

**Author:** ![santoshturamari](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/ee59a6/32.png) [@santoshturamari](https://www.ruby-forum.com/u/santoshturamari)\
**Post date:** [December 15, 2009, 10:58am UTC](https://www.ruby-forum.com/t/how-to-avoid-net-smtpfatalerror-555-5-5-2-syntax-error/166254/7 "2009-12-15T10:58:59Z")

</div>

Any updates on how we can send a @from with a name before the email  
address?

I want to be able to send emails using the [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) email  
address but show ‘Monaqasat’ as the name of the sender.

Thx.

.Karim

Bruno Brunagh wrote:

> Aslam S. wrote:
> 
> > Hello all,
> > 
> > I am trying to send email and written code like this:
> > 
> > `
> > def matches_for_request( contact, req, matching_offers )
> > recipients "#{contact}"
> > from "removed_email_address@domain.invalid"
> > subject "Matches found for your request"
> > sent_on Time.now
> > ```
> > body[:offers] = matching_offers
> > 
> > ```
> > `
> > 
> > `end
> > `
> > 
> > I also had put angled brackets in the from address like  
> > “[removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)”. However, as Chris’s reply suggets I tried  
> > removing the angled brackets. But, this did not solve my problem. I am  
> > continuing to get the following error message:
> > 
> > 555 5.5.2 Syntax error. 23sm387874pxi.9
> > 
> > Please help.
> 
> Hi all,  
> I have the same issue:  
> Net::SMTPFatalError 555 using rails 2.3.3  
> under development environment
> 
> I both tried with or without angle brackets in the @from parameter,  
> but with no help.
> 
> Any idea?
> 
> Thanks

---

<div class="post-metadata">

**Author:** ![santoshturamari](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/ee59a6/32.png) [@santoshturamari](https://www.ruby-forum.com/u/santoshturamari)\
**Post date:** [June 17, 2010, 11:15am UTC](https://www.ruby-forum.com/t/how-to-avoid-net-smtpfatalerror-555-5-5-2-syntax-error/166254/8 "2010-06-17T11:15:43Z")

</div>

Try to do like this:  
from “Monaqasat [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)”  
headers “return-path” =\> 'removed\_email\_address@domain.invalid’

It worked for me !!!

Thanks,  
Nimesh N.

Karim Helal wrote:

> Any updates on how we can send a @from with a name before the email  
> address?
> 
> I want to be able to send emails using the [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) email  
> address but show ‘Monaqasat’ as the name of the sender.
> 
> Thx.
> 
> .Karim
> 
> Bruno Brunagh wrote:
> 
> > Aslam S. wrote:
> > 
> > > Hello all,
> > > 
> > > I am trying to send email and written code like this:
> > > 
> > > `
> > > def matches_for_request( contact, req, matching_offers )
> > > recipients "#{contact}"
> > > from "removed_email_address@domain.invalid"
> > > subject "Matches found for your request"
> > > sent_on Time.now
> > > ```
> > > body[:offers] = matching_offers
> > > 
> > > ```
> > > `
> > > 
> > > `end
> > > `
> > > 
> > > I also had put angled brackets in the from address like  
> > > “[removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)”. However, as Chris’s reply suggets I tried  
> > > removing the angled brackets. But, this did not solve my problem. I am  
> > > continuing to get the following error message:
> > > 
> > > 555 5.5.2 Syntax error. 23sm387874pxi.9
> > > 
> > > Please help.
> > 
> > Hi all,  
> > I have the same issue:  
> > Net::SMTPFatalError 555 using rails 2.3.3  
> > under development environment
> > 
> > I both tried with or without angle brackets in the @from parameter,  
> > but with no help.
> > 
> > Any idea?
> > 
> > Thanks

---

<div class="post-metadata">

**Author:** ![santoshturamari](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/ee59a6/32.png) [@santoshturamari](https://www.ruby-forum.com/u/santoshturamari)\
**Post date:** [June 17, 2010, 4:22pm UTC](https://www.ruby-forum.com/t/how-to-avoid-net-smtpfatalerror-555-5-5-2-syntax-error/166254/9 "2010-06-17T16:22:04Z")

</div>

use action mailer optional tls

> **[GMail SMTP with Ruby on Rails and ActionMailer](https://douglasfshearer.com/2008/01/20/gmail-smtp-with-ruby-on-rails-and-actionmailer.html)**
>
> Trying to use GMail SMTP (or some other SMTP authenticated with TLS) with ActiveRecord to send email in Ruby on Rails? Up till now this involved requiring sm...

On Thu, Jun 17, 2010 at 2:45 PM, Nimesh N. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> > Any updates on how we can send a @from with a name before the email
> > 
> > > Aslam S. wrote:
> > > 
> > > >
> 
> To post to this group, send email to [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid).  
> To unsubscribe from this group, send email to  
> [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)[removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
> .  
> For more options, visit this group at  
> [http://groups.google.com/group/rubyonrails-talk?hl=en](http://groups.google.com/group/rubyonrails-talk?hl=en).

–  
Thanks:  
Rajeev sharma

---

<div class="post-metadata">

**Author:** ![santoshturamari](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/ee59a6/32.png) [@santoshturamari](https://www.ruby-forum.com/u/santoshturamari)\
**Post date:** [September 18, 2009, 12:50pm UTC](https://www.ruby-forum.com/t/how-to-avoid-net-smtpfatalerror-555-5-5-2-syntax-error/166254/10 "2009-09-18T12:50:12Z")

</div>

Aslam S. wrote:

> Hello all,
> 
> I am trying to send email and written code like this:
> 
> `
> def matches_for_request( contact, req, matching_offers )
> recipients "#{contact}"
> from "removed_email_address@domain.invalid"
> subject "Matches found for your request"
> sent_on Time.now
> ```
> body[:offers] = matching_offers
> 
> ```
> `
> 
> `end
> `
> 
> I also had put angled brackets in the from address like  
> “[removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)”. However, as Chris’s reply suggets I tried  
> removing the angled brackets. But, this did not solve my problem. I am  
> continuing to get the following error message:
> 
> 555 5.5.2 Syntax error. 23sm387874pxi.9
> 
> Please help.

Hi all,  
I have the same issue:  
Net::SMTPFatalError 555 using rails 2.3.3  
under development environment

I both tried with or without angle brackets in the @from parameter,  
but with no help.

Any idea?

Thanks
