ASPN ActiveState Programmer Network
ActiveState
/ Home / Perl / PHP / Python / Tcl / XSLT /
/ Safari / My ASPN /
Cookbooks | Documentation | Mailing Lists | Modules | News Feeds | Products | User Groups


Recent Messages
List Archives
About the List
List Leaders
Subscription Options

View Subscriptions
Help

View by Topic
ActiveState
.NET Framework
Open Source
Perl
PHP
Python
Tcl
Web Services
XML & XSLT

View by Category
Database
General
SOAP
System Administration
Tools
User Interfaces
Web Programming
XML Programming


MyASPN >> Mail Archive >> ruby-talk
ruby-talk
Re: How can I get the subject of mail
by Mike Stok other posts by this author
Jun 1 2008 5:08AM messages near this date
Re: How can I get the subject of mail | I am able to upload a 28 meg file, yet php.ini limits posts to 10 megs. What is up with that?
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1


On Jun 1, 2008, at 1:54 AM, Jmlover wrote:

>  On Jun 1, 2:23 am, Craig <cwilli...@[...].net> wrote:
> > On May 31, 1:46 am, Jmlover <Jmlo...@[...].com> wrote:
> >
> >>    @pop = Net::POP3.new('pop.163.com')
> >>    @pop.start(@username, @password)
> >
> >>    @pop.each_mail do |m|
> >>              # How can I get the subject of mï¼?
> >>        # ã??ã??ã??ã??ã??ã??ã??ã??ã??ã??ã??ã??ã??ã??ã??ã??
> >>        # By m.pop?
> >>    end
> >
> >>    @pop.finish
> >
> >> By the way, can I only get the mail header? How?
> >
> >> Thank you!
> >
> > Here is one way.
> >
> > puts m.pop.scan(/Subject:(.+)$/)
> >
> > Cheers,
> >
> > Craig
> 
>  Thank you for your reply!

You can use the header method if you are only interested in the header:

#!/usr/bin/env ruby

require 'net/pop'
pop = Net::POP.new('pop.example.com')
pop.start('user@example.com', 'password') do |pop|
    pop.each_mail do |mail|
       puts mail.header.scan(/^Subject: (.+)/)
    end
end

http://www.ruby-doc.org/stdlib/libdoc/net/pop/rdoc/classes/Net/POPMail.html

Mike

- --

Mike Stok <mike@[...].ca> 
http://www.stok.ca/~mike/

The "`Stok' disclaimers" apply.




-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (Darwin)

iEYEARECAAYFAkhCkQkACgkQnsTBwAWZE9rFAgCfdfz9a7fGAAmLNlt7Tolgj9J/
Xb4AoIe1vxT1NBZ/01iFeirSLOSChPrR
=Bqet
-----END PGP SIGNATURE-----
Thread:
Jmlover
Craig
Jmlover
Mike Stok

Privacy Policy | Email Opt-out | Feedback | Syndication
© ActiveState Software Inc. All rights reserved