# Receiving mail from not strictly RFC-valid email addresses

**URL:** <https://www.ruby-forum.com/t/receiving-mail-from-not-strictly-rfc-valid-email-addresses/142994>\
**Category:** Rails\
**Created:** [July 14, 2008, 10:36am UTC](https://www.ruby-forum.com/t/receiving-mail-from-not-strictly-rfc-valid-email-addresses/142994 "2008-07-14T10:36:52Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![macdigger](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/13edae/32.png) [@macdigger](https://www.ruby-forum.com/u/macdigger)\
**Post date:** [July 14, 2008, 10:36am UTC](https://www.ruby-forum.com/t/receiving-mail-from-not-strictly-rfc-valid-email-addresses/142994/1 "2008-07-14T10:36:52Z")

</div>

Hello,

I have a blog system which allows users to post articles to their blogs  
from mobile phones.

Users just set up their mobile phone address in blog settings and then  
send messages from mobile phone to designated server email, which is  
then parsed and added to their respectful blogs based on the From:  
field.

However, being in Japan and having Japanese mobile phone users setting  
their email addresses to very strange, RFC-invalid, but still perfectly  
working email addresses (and mobile operators allowing them to do so…)

- I have problem that non-RFC valid emails get killed during the  
Mailer.receive phase and never actually make it to their blogs.

For example, an email address can easily be in a form like  
“removed\_email\_address@domain.invalid”

As far as I understand, TMail’s Address.parse is responsible for parsing  
stuff which comes to Mailer.receive function.

However, it shows error on addresses like that:

> > TMail::Address.parse(“removed\_email\_address@domain.invalid”)  
> > TMail::SyntaxError: parse error on token “.”  
> > from parser.y:379:in `on\_error’

What I would like to do is to make the parser less strict.

I tried to understand how TMail’s parser works and almost broke my neck  
☹  
I would be really grateful if anyone can suggest a solution, or at least  
give a direction where I should look for a solution.  
Mail addresses are processes by TMail::Parser (and I don’t understand  
the syntax…), but it should come to RegExp matching at some point? I  
don’t know. Any suggestions are very very welcome.

Thanks  
Mike.
