Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ruby-on-rails/64.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby on rails Rails使用IMAP访问Yahoo邮件-解析电子邮件_Ruby On Rails_Imap_Yahoo - Fatal编程技术网

Ruby on rails Rails使用IMAP访问Yahoo邮件-解析电子邮件

Ruby on rails Rails使用IMAP访问Yahoo邮件-解析电子邮件,ruby-on-rails,imap,yahoo,Ruby On Rails,Imap,Yahoo,无法分析从Yahoo电子邮件访问的电子邮件 require 'net/imap' def index conn = Net::IMAP.new('imap.mail.yahoo.com', 993, ssl:true) conn.login("email", "mypassword") conn.select("INBOX") conn.uid_search(['ALL']).each do |uid| source = conn.uid_fetch(uid, ['

无法分析从Yahoo电子邮件访问的电子邮件

require 'net/imap'
def index
  conn = Net::IMAP.new('imap.mail.yahoo.com', 993, ssl:true)
  conn.login("email", "mypassword")

  conn.select("INBOX")
  conn.uid_search(['ALL']).each do |uid|
    source   = conn.uid_fetch(uid, ['RFC822']).first.attr['RFC822']
  end
end
新输出我只收到了第一封邮件,而不是第二封。在第二封邮件中,我只收到了一行,其余的文本丢失了,我还收到了输出中不需要的html内容。

Welcome to Yahoo



--------------------------------------------------------------------


http://in.yahoo.com

--------------------------------------------------------------------

Welcome!

Your Yahoo username is now active.

Dear aniketshivamtiwari,

Everyday we're working hard to make your daily habits more inspiring and entertaining. While you're here, check out the amazing new features available on Flickr, the all-new Yahoo Weather app, and Yahoo Mail for mobile and tablet.

Yahoo Homepage:
http://in.yahoo.com/

Flickr:
http://www.flickr.com/

Yahoo Weather app:
https://in.mobile.yahoo.com/weather/

Yahoo Mail:
http://in.overview.mail.yahoo.com/mobile/

If you have any questions or need additional support, 
please visit our Help Center.
http://help.yahoo.com/kb/index?page=product&y=PROD_MAIL_ML&locale=en_IN

Thanks and have a great day.

Yahoo Customer Care  

--------------------------------------------------------------------

Privacy Policy
http://info.yahoo.com/privacy/in/yahoo/

Web Beacons in Email
http://info.yahoo.com/privacy/in/yahoo/webbeacons/E13

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Yahoo</title>
</head>

<body bgcolor="#C0C0C0" style="padding: 0; margin: 0;" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0"><IMG SRC="https://email.communications.yahoo.com/t/dbdbaEFWF6CAA2DsKXyCTXDaaC3a4X0-2~aaaa?r=ybu**y**JRLA**bKXGbObIZUNBLWEP6KNTbTGJGN@B@&amp;b=dklhhqvelsdjwfzXuf_1Xklr.fq&amp;i=" WIDTH="1" HEIGHT="1" STYLE="border:0px hidden transparent !important; display:none !important; max-height:0;" ALT=""/>
<table align="center" width="100%" valign="top" border="0" cellspacing="0" cellpadding="0" bgcolor="#C0C0C0" style="font-family:Arial,sans-serif;" dir="">
<tr>
<td align="center" valign="top">
    <table cellpadding="0" cellspacing="0" width="500" align="center" border="0" style="min-width:500px;">
    <tr>
    <td width="500" align="center">

<!--Preheader-->

<!--Preheader End-->

<!-- Logo Start -->
    <table width="500" border="0" cellspacing="0" cellpadding="0" bgcolor="#400090">
    <tr>
    <td width="20" height="83">&nbsp;</td>
    <td width="140" valign="middle"><a href="http://in.yahoo.com"><img src="http://l.yimg.com/dh/ap/default/131029/yahoo_logo.png" width="140" alt="Yahoo" border="0" style="display:block;"></a></td>
    <td width="340">&nbsp;</td>
    </tr>
    </table>
<!-- Logo End --> 

<!-- Hero Start -->     
    <table align="center" width="500" border="0" cellspacing="0" cellpadding="0">
    <tr>
    <td width="500"><img src="http://l.yimg.com/dh/ap/default/131105/hero.jpg" alt="" width="500" height="280" border="0" style="display:block;"></td>
    </tr>
    </table>
<!-- Hero End -->

<!-- Headline Start -->
    <table align="center" width="500" border="0" cellspacing="0" cellpadding="0" bgcolor="#ffffff">
    <tr>
    <td width="21">&nbsp;</td>
    <td align="left">
        <table valign="top" width="458" border="0" cellspacing="0" cellpadding="0">
        <tr>
        <td height="20" style="font-size:20px; line-height:20px;">&nbsp;</td>
        </tr>
        <tr>
        <td style="font-family:Arial,sans-serif; font-size:23px; line-height:23px; color:#6D329C;">Your Yahoo username is now active.</td>
        </tr>
        <tr>
        <td height="20" style="font-size:20px; line-height:20px;">&nbsp;</td>
        </tr>
        </table>
    </td>
    <td width="21">&nbsp;</td>
    </tr>
    </table>
<!-- Headline End -->

<!-- Content -->
<table align="center" width="500" border="0" cellspacing="0" cellpadding="0" bgcolor="#464958">
    <tr>
    <td width="22">&nbsp;</td>
    <td width="456" align="left" style="font-size:13px; line-height:21px; color:#8C8F9E;">
        <table valign="top" width="456" border="0" cellspacing="0" cellpadding="0" >
        <tr>
        <td height="28" style=" font-size:28px; line-height:28px;">&nbsp;</td>
        </tr>
        <tr>
        <td style="font-size:15.5px; line-height:21px; color:#ffffff; font-weight:bold;">Dear aniketshivamtiwari,</td>
        </tr>
        <tr>
        <td height="20" style="font-size:20px; line-height:20px;">&nbsp;</td>
        </tr>
        <tr>
        <td style="font-family:Arial,sans-serif; font-size:13px; line-height:21px; color:#ffffff;">Everyday we're working hard to make your daily habits more inspiring and entertaining. While you're here, check out the amazing new features available on <a href="http://www.flickr.com" style="font-family:Arial,sans-serif;font-size:12px;line-height:normal;color:#ffffff;text-decoration:underline;" target="_blank">Flickr</a>, the all-new <a href="https://in.mobile.yahoo.com/weather/" style="font-family:Arial,sans-serif;font-size:12px;line-height:normal;color:#ffffff;text-decoration:underline;" target="_blank">Yahoo Weather</a> app, and <a href="http://in.overview.mail.yahoo.com/mobile/" style="font-family:Arial,sans-serif;font-size:12px;line-height:normal;color:#ffffff;text-decoration:underline;" target="_blank">Yahoo Mail</a> for mobile and tablet.</td>
        </tr>
        <tr>
        <td height="20" style="font-size:20px; line-height:20px;">&nbsp;</td>
        </tr>
        <tr>
        <td style="font-family:Arial,sans-serif; font-size:13px; line-height:21px; color:#ffffff;">If you have any questions or need additional support, please visit our <a href="http://help.yahoo.com/kb/index?page=product&y=PROD_MAIL_ML&locale=en_IN" style="font-family:Arial,sans-serif;font-size:12px;line-height:normal;color:#ffffff;text-decoration:underline;" target="_blank">Help Center</a>.</td>
        </tr>
        <tr>
        <td height="20" style="font-size:20px; line-height:20px;">&nbsp;</td>
        </tr>
        <tr>
        <td height="21" style="font-family:Arial,sans-serif; font-size:13px; line-height:21px; color:#ffffff;">Thanks and have a great day.</td>
        </tr>
        <tr>
        <td height="35" style="font-size:35px; line-height:35px;">&nbsp;</td>
        </tr>
        </table>
    </td>
    <td width="22">&nbsp;</td>
    </tr>
</table>
<!-- Content End -->

<!-- Footer Banner -->
    <table width="500" border="0" cellspacing="0" cellpadding="0" bgcolor="#686F7F">
    <tr>
    <td width="20">&nbsp;</td>
    <td align="left">
        <table width="460" cellpadding="0" cellspacing="0" border="0">
        <tr>
        <td height="31" style=" font-size:28px; line-height:28px;">&nbsp;</td>
        </tr>
        <tr>
        <td width="460" style="font-family:Arial,sans-serif; font-size:22px; line-height:21px; color:#ffffff;">Yahoo Customer Care</td>
        </tr>
        <tr>
        <td height="30" style=" font-size:28px; line-height:28px;">&nbsp;</td>
        </tr>
        <tr>
        </table>
    </td>
    <td width="20">&nbsp;</td>
    </tr>
    </table>
<!-- Footer Banner End -->


<!--Footer-->
<table align="center" width="500" border="0" cellspacing="0" cellpadding="0" bgcolor="#F4F3F8">
    <tr><td width="20">&nbsp;</td>
        <td width="460" align="left" valign="top" >
            <table width="460" border="0" cellspacing="0" cellpadding="0">
                <tr><td width="1" style="line-height:22px">&nbsp;</td></tr>
                <tr><td><a href="https://email.communications.yahoo.com/t/dcdbaEFWF6CAA2DsKXyCTXDaaC3a4X0-2~aaaa?r=ybu**y**JRLA**bKXGbObIZUNBLWEP6KNTbTGJGN@B@&amp;b=dklhhqvelsdjwfzXuf_1Xklr.fq&amp;i=E0t&amp;u=&amp;u=ewqs://fqcr.vderl.flp/mufyXfv/lk/1Xklr/4578B7D221B27B7664D0BEF428E0856C6C8D06331F9D7350A397541C39A8FE5B" style="font-family:Arial,sans-serif; font-size:12px; line-height:normal; color:#333333;text-decoration:underline;">Privacy Policy</a>&nbsp;&nbsp;|&nbsp;&nbsp;
                        <a href="https://email.communications.yahoo.com/t/dcdbaEFWF6CAA2DsKXyCTXDaaC3a4X0-2~aaaa?r=ybu**y**JRLA**bKXGbObIZUNBLWEP6KNTbTGJGN@B@&amp;b=dklhhqvelsdjwfzXuf_1Xklr.fq&amp;i=E0u&amp;u=&amp;u=ewqs://fqcr.vderl.flp/mufyXfv/lk/1Xklr/thYebdZrkv/B407C67DE06C54FE81854824B429D6B0BD263D4F2659AF544407499E6836E7557F3" style="font-family:Arial,sans-serif; font-size:12px; line-height:normal; color:#333333;text-decoration:underline;">Web Beacons in Email</a>
                    </td>
                </tr>
                <tr><td width="1" style="line-height:24px">&nbsp;</td></tr>
            </table>
        </td>
        <td width="20">&nbsp;</td>
    </tr>
</table>
<!--Footer End-->

    </td>
    </tr>
    </table>

</td>
</tr>
</table>
</body>
</html>
Password change for your Yahoo account


<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<style type="text/css">
        html { -webkit-text-size-adjust:none; }
        body { width:100%; margin:0 auto; padding:0; }
        .ReadMsgBody { width: 100%; }
        .ExternalClass { width: 100%; }
    .iosLinkPurple a { color:#400090; text-decoration:none; }
    .iosLinkGrey a { color:#454958; text-decoration:none; }
    .iosLinkSlate a { color:#424242; text-decoration:none; }
</style>
<!--[if gte mso 15]>
<style type="text/css" media="all">
ol,li {
    margin: 0;
    padding: 0;
    -webkit-text-size-adjust: 100%;
}
ol {
    counter-reset: foo;
    display: table;
    padding: 23px;
}
</style>
<![endif]-->

<!--[if gte mso 9]>
<style type="text/css">
.m1930{margin-left:19px; margin-right:30px;}
</style>
<![endif]-->

</head>
<body>
<div>
<table cellpadding="0" cellspacing="0" bgcolor="#ffffff" width="100%" style="table-layout:fixed;">
<tbody>
<tr>
    <td align="center" valign="top" style="min-width:500px;" >

        <table cellspacing="0" cellpadding="0" width="500" bgcolor="#400090">
        <tr>
            <td><a href="#"><img src="https://s.yimg.com/sf/email/logo.gif" style="display:block; border:0;" width="500" height="87" /></a></td>
        </tr>
        </table>
        <table cellspacing="0" cellpadding="0" width="500" bgcolor="#f4f3f8">
        <tr>
            <td >

                <table cellspacing="0" cellpadding="0"><tr><td height="23" style="line-height:23px;"><img src="images/sp.gif" height="1" width="1" style="display:block; border:0;" /></td></tr></table>

<div class="m1930" style="font-family:Helvetica, Verdana, Arial, sans-serif; font-size:17px; line-height:21px; color:#464958; padding-left:19px; padding-right:30px;">
                     Hello Aniket,<br/>
                    <table cellspacing="0" cellpadding="0"><tr><td height="14" style="line-height:14px;"><img src="images/sp.gif" height="1" width="1" style="display:block; border:0;" /></td></tr></table>
            The password for your Yahoo account, <b>&lrm;an**************ri&lrm;</b>, was recently changed.
            <br>
                    <table cellspacing="0" cellpadding="0"><tr><td height="14" style="line-height:14px;"><img src="images/sp.gif" height="1" width="1" style="display:block; border:0;" /></td></tr></table>
        If you made this change, you�re all set.<br><br>
<div style="background-color:#eae9ee; font-size: 15px;padding: 24px;padding-top:10px;padding-bottom: 10px;">
<p style="padding-left:9px">

If not, please take these steps to secure your account:
</p>
<ol  style="padding-left:25px">
<li>
Reset your password on any sign-in screen by selecting the <a href="https://edit.yahoo.com/config/eval_forgot_pw?.intl=in&.lang=en-IN" target="_blank">I can�t access my account</a>link.
</li>
<br>
<li>
Visit the Yahoo <a href="https://security.yahoo.com" target="_blank">Security Centre</a>to learn how to protect against malicious activity.
</li>
</ol>
<p style="padding-left:9px">
Feel free to contact <a href="https://io.help.yahoo.com/contact/index?page=contactform&locale=en_US&token=w5FCchB1dWFBK0e02%252BwEyuLoMKXEj8hiMaAs%252B8Qhn9Fh%252FFMQCC3ebEMZfW125VoXEPU0mYntyapqUt3Om%252BB5MDOlh33Rl0Gx6HB0ZEOq2Z3DeGCPpmGP05SOzmmkLPGu3%252FF8rDTGhm4%253D&selectedChannel=email-icon#voice-form" target="_blank">Customer Care</a> with any questions or concerns.
</p>
</div>
                    <table cellspacing="0" cellpadding="0"><tr><td height="14" style="line-height:14px;"><img src="images/sp.gif" height="1" width="1" style="display:block; border:0;" /></td></tr></table>
            Thanks, <br>
            Yahoo
                </div>

                <table cellspacing="0" cellpadding="0"><tr><td height="24" style="line-height:24px;"><img src="images/sp.gif" height="1" width="1" style="display:block; border:0;" /></td></tr></table>

                <!-- black line -->
                <table cellspacing="0" cellpadding="0" bgcolor="#687080" width="500"><tr><td height="1" style="line-height:1px;"><img src="images/sp.gif" height="1" width="1" style="display:block; border:0;" /></td></tr></table>
                <!-- /line -->

            </td>
        </tr>
        </table>
        <!-- /body -->
<table cellspacing="0" cellpadding="0"><tr><td height="16" style="line-height:16px;"></td></tr></table>

        <table cellspacing="0" width="500" style="table-layout:fixed;">
        <tr>
            <td align="left">
                <table cellspacing="0" cellpadding="0"><tr><td height="19" style="line-height:19px;"></td></tr></table>
                <div style="font-family:Helvetica, sans-serif; font-size:13px; line-height:18px; color:#333333;">
                  Replies sent to this email address cannot be answered.
                </div>
                <table cellspacing="0" cellpadding="0"><tr><td height="14" style="line-height:14px;"></td></tr></table>
            </td>
        </tr>
        </table>
    </td>
</tr>
</tbody>
</table>
</div>

</body>
</html>
欢迎来到雅虎
--------------------------------------------------------------------
http://in.yahoo.com
--------------------------------------------------------------------
欢迎
您的雅虎用户名现在处于活动状态。
亲爱的aniketshivamtiwari,
我们每天都在努力让你的日常习惯更具启发性和娱乐性。在这里,您可以查看Flickr、全新的Yahoo Weather应用程序以及Yahoo Mail for mobile和tablet上提供的惊人新功能。
雅虎主页:
http://in.yahoo.com/
Flickr:
http://www.flickr.com/
雅虎天气应用程序:
https://in.mobile.yahoo.com/weather/
雅虎邮件:
http://in.overview.mail.yahoo.com/mobile/
如果您有任何问题或需要其他支持,
请访问我们的帮助中心。
http://help.yahoo.com/kb/index?page=product&y=PROD_MAIL_ML&locale=en_IN
谢谢,祝你今天愉快。
雅虎客户关怀
--------------------------------------------------------------------
隐私政策
http://info.yahoo.com/privacy/in/yahoo/
电子邮件中的网络信标
http://info.yahoo.com/privacy/in/yahoo/webbeacons/E13
雅虎
您的雅虎用户名现在处于活动状态。
亲爱的aniketshivamtiwari,
我们每天都在努力让你的日常习惯更具启发性和娱乐性。在这里,您可以查看全新应用程序上以及手机和平板电脑上的惊人新功能。
如果您有任何问题或需要其他支持,请访问我们的。
谢谢,祝你今天愉快。
雅虎客户关怀
|  
为您的雅虎帐户更改密码
html{-webkit文本大小调整:无;}
正文{宽度:100%;边距:0自动;填充:0;}
.ReadMsgBody{宽度:100%;}
.ExternalClass{宽度:100%;}
.iosLinkPurple a{color:#400090;文本装饰:无;}
.iosLinkGrey a{color:#454958;文本装饰:无;}
.iosLinkSlate a{color:#424242;文本装饰:无;}
你好,安妮特,
雅虎帐户的密码&lrm;an******************ri&lrm;,最近发生了变化。
如果你做了这个改变,你�重新设置。

如果没有,请采取以下步骤保护您的帐户:

  • 通过选择链接,在任何登录屏幕上重置密码。

  • 访问雅虎,了解如何防范恶意活动。
  • 请随时联系任何问题或顾虑。

    谢谢,
    雅虎 无法答复发送到此电子邮件地址的答复。
    注意:安装gem'mail'用于解析电子邮件

    尝试
    conn.select(“收件箱”)
    require 'net/imap'
    def index
      conn = Net::IMAP.new('imap.mail.yahoo.com', 993, ssl:true)
      conn.login("email", "mypassword")
    
      conn.select("INBOX")
      conn.uid_search(['ALL']).each do |uid|
        # fetches the straight up source of the email for ymail to parse
        msg = conn.fetch(uid, 'RFC822').first.attr['RFC822']
    
        mail = Mail.read_from_string msg
        puts mail.subject
        puts mail.text_part.body.to_s
        puts mail.html_part.body.to_s
      end
    end