我正在使用postfix邮件服务器,并且我通过别名将传入的电子邮件发送到控制器:
v2mail1: |"/var/www/html/dev/rails/v2p0/script/email_handler.sh incoming_email development"
在email_handler.sh
我将电子邮件从标准输入传递给控制器作为POST消息:
/usr/bin/curl -F email='<-' -s -f $base_url/$1
所以我将整个电子邮件作为控制器中的字符串。如何解析此字符串以获取to
,cc
,subject
,body
,attachments
等。我没有找到任何宝石。例如。字符串:
"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: by centos1.tibi1959.hu (Postfix, from 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 from ntibor to 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"
答案 0 :(得分:0)