Receiving mail from not strictly RFC-valid email addresses


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:

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
[email protected]

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(“[email protected]”)
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.