parsing - How can I parse an email passed as a string in Rails 3 -
i'm using postfix mail server , i'm sending incoming emails controller through alias:
v2mail1: |"/var/www/html/dev/rails/v2p0/script/email_handler.sh incoming_email development"
in email_handler.sh
i'm passing email standard input controller post message:
/usr/bin/curl -f email='<-' -s -f $base_url/$1
so whole email string in controller. how can parse string to
, cc
, subject
, body
, attachments
, etc. did not find gem that. e.g. string:
"from nagyt@hu.inter.net fri jun 27 11:14:28 2014\nreturn-path: <nagyt@hu.inter.net>\nx-original-to: v2mail1\ndelivered-to: v2mail1@centos1.tibi1959.hu\nreceived: centos1.tibi1959.hu (postfix, userid 276)\n\tid c0dc7283a04; fri, 27 jun 2014 10:18:59 +0200 (cest)\ndate: fri, 27 jun 2014 10:18:59 +0200\nto: v2mail1@centos1.tibi1959.hu\nsubject: test ntibor v2mail1\nuser-agent: heirloom mailx 12.5 7/5/10\nmime-version: 1.0\ncontent-type: text/plain; charset=us-ascii\ncontent-transfer-encoding: 7bit\nmessage-id: <20140627081859.c0dc7283a04@centos1.tibi1959.hu>\nfrom: nagyt@hu.inter.net (nagy tibor)\n\ntest\n"
i've found simplest way parse raw email text:
mail = mail.new raw_mail
in case mail
instance of mail::message, of methods need access mail attributes, attachments easily.
Comments
Post a Comment