gotmail-0.9.0/0000744000175000017500000000000010606723177011647 5ustar paulpaulgotmail-0.9.0/COPYING0000644000175000017500000004311010545475440012702 0ustar paulpaul GNU GENERAL PUBLIC LICENSE Version 2, June 1991 Copyright (C) 1989, 1991 Free Software Foundation, Inc. 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This General Public License applies to most of the Free Software Foundation's software and to any other program whose authors commit to using it. (Some other Free Software Foundation software is covered by the GNU Library General Public License instead.) You can apply it to your programs, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things. To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it. For example, if you distribute copies of such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software. Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations. Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that redistributors of a free program will individually obtain patent licenses, in effect making the program proprietary. To prevent this, we have made it clear that any patent must be licensed for everyone's free use or not licensed at all. The precise terms and conditions for copying, distribution and modification follow. GNU GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any derivative work under copyright law: that is to say, a work containing the Program or a portion of it, either verbatim or with modifications and/or translated into another language. (Hereinafter, translation is included without limitation in the term "modification".) Each licensee is addressed as "you". Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running the Program is not restricted, and the output from the Program is covered only if its contents constitute a work based on the Program (independent of having been made by running the Program). Whether that is true depends on what the Program does. 1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and give any other recipients of the Program a copy of this License along with the Program. You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. 2. You may modify your copy or copies of the Program or any portion of it, thus forming a work based on the Program, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: a) You must cause the modified files to carry prominent notices stating that you changed the files and the date of any change. b) You must cause any work that you distribute or publish, that in whole or in part contains or is derived from the Program or any part thereof, to be licensed as a whole at no charge to all third parties under the terms of this License. c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the most ordinary way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this License. (Exception: if the Program itself is interactive but does not normally print such an announcement, your work based on the Program is not required to print an announcement.) These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Program, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Program, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Program. In addition, mere aggregation of another work not based on the Program with the Program (or with a work based on the Program) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. 3. You may copy and distribute the Program (or a work based on it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you also do one of the following: a) Accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, b) Accompany it with a written offer, valid for at least three years, to give any third party, for a charge no more than your cost of physically performing source distribution, a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, c) Accompany it with the information you received as to the offer to distribute corresponding source code. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form with such an offer, in accord with Subsection b above.) The source code for a work means the preferred form of the work for making modifications to it. For an executable work, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the executable. However, as a special exception, the source code distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. If distribution of executable or object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place counts as distribution of the source code, even though third parties are not compelled to copy the source along with the object code. 4. You may not copy, modify, sublicense, or distribute the Program except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense or distribute the Program is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. 5. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Program or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Program (or any work based on the Program), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Program or works based on it. 6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties to this License. 7. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Program at all. For example, if a patent license would not permit royalty-free redistribution of the Program by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Program. If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply and the section as a whole is intended to apply in other circumstances. It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system, which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. 8. If the distribution and/or use of the Program is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Program under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. 9. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of this License, you may choose any version ever published by the Free Software Foundation. 10. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Also add information on how to contact you by electronic and paper mail. If the program is interactive, make it output a short notice like this when it starts in an interactive mode: Gnomovision version 69, Copyright (C) year name of author Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, the commands you use may be called something other than `show w' and `show c'; they could even be mouse-clicks or menu items--whatever suits your program. You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the program, if necessary. Here is a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the program `Gnomovision' (which makes passes at compilers) written by James Hacker. , 1 April 1989 Ty Coon, President of Vice This General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Library General Public License instead of this License. gotmail-0.9.0/Makefile0000644000175000017500000000155610606652347013320 0ustar paulpaul# # Makefile for gotmail # # Copyright 2005, Jon Phillips & Paul Howarth. # # It basically just installs gotmail and the manpage into the # right places and also provides a mechanism to remove them. # APPNAME = gotmail PREFIX = /usr EXEC_PREFIX = $(PREFIX) BINDIR = $(EXEC_PREFIX)/bin MANDIR = $(PREFIX)/man MAN1DIR = $(MANDIR)/man1 DESTDIR = all: $(APPNAME).1.gz install: all install -p -m 755 -d $(DESTDIR)$(BINDIR) install -p -m 755 -d $(DESTDIR)$(MAN1DIR) install -p -m 755 $(APPNAME) $(DESTDIR)$(BINDIR) install -p -m 644 $(APPNAME).1.gz $(DESTDIR)$(MAN1DIR) uninstall: rm $(DESTDIR)$(BINDIR)/$(APPNAME) rm $(DESTDIR)$(MANDIR)/$(APPNAME).1.gz clean: rm -f $(APPNAME).1.gz $(APPNAME).1.gz: $(APPNAME).man touch -r $(APPNAME).man timestamp cat $(APPNAME).man | gzip -c > $(APPNAME).1.gz touch -r timestamp $(APPNAME).1.gz .PHONY: all install uninstall clean gotmail-0.9.0/VERSION0000644000175000017500000000000610606700747012713 0ustar paulpaul0.9.0 gotmail-0.9.0/gotmail.spec0000644000175000017500000000402210606723163014152 0ustar paulpaulSummary: Fetch mail out of your Hotmail or MSN account Name: gotmail Version: 0.9.0 Release: 1 Epoch: 1 License: GPL Group: Applications/Internet URL: http://sourceforge.net/projects/gotmail/ BuildArch: noarch Source: http://downloads.sourceforge.net/gotmail/gotmail-%{version}.tar.bz2 # Source: http://easynews.dl.sourceforge.net/sourceforge/gotmail/gotmail-%{version}.tar.bz2 Requires: curl >= 7.9.8 BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root %description This is Gotmail, a perl script to fetch mail out of your Hotmail or MSN account. This is especially useful if you want to move from Hotmail into one of the other free mail services - one command can do it all. Gotmail also supports getting any new mail only from your Hotmail or MSN account - perfect for using a Hotmail account as a redirect address into another account. %prep %setup -q %build %{__make} %install %{__rm} -rf "%{buildroot}" %{__make} install DESTDIR="%{buildroot}" \ BINDIR="%{_bindir}" \ MANDIR="%{_mandir}" \ MANCOMPRESS= \ INSTALL="%{__install} -p" %clean %{__rm} -rf "%{buildroot}" %files %defattr(-,root,root,-) %doc COPYING ChangeLog README sample.gotmailrc gotmail4evolution %{_bindir}/gotmail %{_mandir}/man1/gotmail.1* %changelog * Wed Apr 11 2007 James Turnbull 1:0.9.0-1 - Removed umask 022 - Reverted back to root attr * Tue Apr 10 2007 James Turnbull 1:0.9.0-0 - Changed download location to downloads.sourgeforge.net - Removed NEWS and PRESSRELEASE files - Added quotation marks around variables - Updated spec file version to 0.9.0 * Mon Oct 09 2006 James Turnbull 1:0.8.9-3 - Reverted Source URL to dl.sf.net and added backup Source * Mon Oct 09 2006 James Turnbull 1:0.8.9-2 - Further changes to spec file for Fedora Extras * Sun Oct 08 2006 James Turnbull 1:0.8.9-1 - Updated spec file for Fedora release * Tue Jul 25 2006 James Turnbull 1:0.8.9-0 - Spec file for Fedora Extras gotmail-0.9.0/gotmail.1.gz0000644000175000017500000000635210606712554014011 0ustar paulpaulFYms6_v E'}e\[ZR&;D$e{ )vzw"ž 4^һ윞jDr󔖊dS"7.xqvlkDq{H^:Tڔ2ei#mHZlURTI=-i~JLĩ“V%$@yFD9])ݣ\hS'b–rN%8D̟ ]>wd(5I]rBe':#л3K(?n+22IL]V$˔D ].(jd3v%K}GC+c ҦYeG$U/k5gDS`gf$/ Pl8יInCPF%z-emzm 5*OҖ\?sq)} \#[Yڪ*~wz\RPÓ"L)Wz][K|s:r5/J^4WR.KXm*UgDz޾PRu^(7O%͋)6Oc5_ñf5(,\+˱ "cUYdO u>q!1kmԶGz̗)s;JGZU1ixGv!Wc+&\ZqzRI 9M|fQ:a@Mbަ@Í5w;Uُ8]:>mkgS!sُEe-45ߗ3N meP M *KZߪOG[FF-M`qEA!d~;ɭޑq}JLF3yoX(S}uZO Sl˔|iDdb3nʝڂ0]שb/`<ĉa?ZԆ̖ #{gm*XitV#zS7@'}`,; Ƕ̍L>wxѥ`z|bOLV3sɪgʎBkEkStX$0Itvp*Fx H5 xm CvN Ҁa;o& mH}T )bՎGB5*gvz7ƥڊ ƪ[mjǺJ+Ȫj%|uoƼCLM=S&E  H]j㕪\UJ=YyxZ*TDr&ƿ?DgJb<. ؾ{Em#Ft^,HqaXCy) vp&j ?ҫq ]xa< WaP};G!5~;NuѴGvf!܉݇#\WʀY?elf.ZF>{`vkʊGpw/}u%JW^F50c:(%~FùG~J|zbga FYΥpPPԥץ2/a!;;aQG00w}8HvIC,tG U;SC5:gyќ:KdG0ׇQsRp578B0KE A/COxkd"NGIMEr3!\ +0a+x d 8?xm3?nM>a܁ ?YX@9Ҵ59jӛ'cP9 G꾏[o#LWjl~MGm+;C꣺ѥ҉!,4+C#G,KL'ѻɗo/ :}?#tv>c%ؐU'A5Zz;9DwIr#? 46YZ.6~Z*>mS]] xߟ^L'ڌӍxX 7g IL?~?bj=w1g[n ʫEܠǂl&|+W|G 9dq;tȋ$Rl&޹KnL,g%t/gʼV^/`B -CbWwӡXG; sv`Sl<\!hV[|hE4܀Q||,KSؕoaLle.#:*S4ܶSj[b.ӚRUm#OjQ!kkyyo,(/N3qI&+o" command to move downloaded mails to the Trash Can instead. .TP .B \-\-move Move mails to the named folder after downloading. .TP .B \-\-speed\-limit Add a small delay after each message to stop the local MTA from being overloaded. .TP .B \-\-retry\-limit num_tries Maximum number of times to retry a download. .TP .B \-\-save\-to\-login When this option is specified, saves messages to "username-foldername" in the folder-dir directory. The Inbox folder is saved to just "username". .TP .B \-\-use\-procmail This option sends all messages only to procmail(1). Options to forward or save to mailboxes are ignored. .TP .B \-\-procmail\-bin /path/to/procmail Allows user to set location of the procmail binary. Default is "/usr/bin/procmail". .TP .B \-\-procmail\-option Pass options through to procmail .TP .B \-\-curl\-bin /path/to/curl Allows user to set location of the curl binary. Default is to search the path. .TP .B \-\-use\-sa Use SpamAssassin to detect junk mail. .TP .B \-\-delete\-spam Delete junk mail instead of just ignoring it (requires \-\-use\-sa option). .TP .B \-\-move\-spam folder Move spam to this folder (requires \-\-use\-sa option). .TP .B \-\-spam\-score score SpamAssassin score to be considered spam. Default is 4.5. .TP .B \-\-nodownload Don't actually download or forward mail. Useful when used with the \-\-delete\-spam option. .TP .B \-\-summary Print the number of messages received one line per folder. .TP .B \-\-remove\-header Automatically remove X-Message-Info header to not trigger X_MESSAGE_INFO rule in SpamAssassin. .SH EXAMPLES Download all the mail from the account of "billyjoe@hotmail.com" with password "sEcReT" and forward it to "john@ab.com". .Sx 3 gotmail \-u billyjoe \-p sEcReT \-f john@ab.com (This is insecure!) .Ex Download, and delete, new mail only in the Inbox and MyMail folders of uro_levu's Hotmail account. Save the resulting mail in mbox files named after the folders ("Inbox" and "MyMail") under the warmmail/ directory. .Sx 3 gotmail \-u uro_levu \-p my_password \-\-delete \-\-only\-new \\ \-\-folder\-dir $HOME/warmmail \-\-folders "Inbox, MyMail" (This is insecure!) .Ex Scan the mail in the Inbox and move anything with a SpamAssassin score of 5 or better to a folder named Spam, but don't actually download anything. .Sx gotmail \-\-folders "Inbox" \-u billyjoe \-p sEcReT \-\-use\-sa \\ \-\-nodownload \-\-move\-spam Spam \-\-spam\-score 5 (This is insecure!) .Ex .SH Configuration Files You can put the configuration for gotmail in a file. This has the significant advantage of not putting your username and password on the command line, where it is possible for others on your machine to read them. By default, gotmail will look for a file in your home directory called ".gotmailrc". You can specify a different one with the \-\-config\-file option. Options on the command line will override options in the configuration file. .PP Configuration files may contain comments (Lines beginning with #). Options in the file are identical to the long arguments listed above, and are assigned values using an = sign. Do not add extra whitespace before or after the =. .PP This very simple configuration file gets all the mail from the account of randomuser@hotmail.com, password "ger0nim34": .Sx 3 # randomuser's gotmailrc file username=randomuser password=ger0nim34 .Ex This slightly more complex example causes gotmail to quietly download and delete all mail in the account of linux@hotmail.com, and forward it to linux@yahoo.com. .Sx 3 # .gotmailrc username=linux password=FreesOftwareForever forward=linux@yahoo.com silent delete .Ex .SH AUTHORS This manual page was written by Peter Hawkins , for the Debian GNU/Linux system (but may be used by others). Additions were made by paul cannon and James Turnbull . Additional contributions from John Fruetel, Jon Phillips, Guyang Mao, Didier CLERC, Leigh Purdie, Sh, Patrick Froede, Herman Mereles, Kamal Kantawala, Andrei Popov, Kamal Mahyuddin, Hindu, Joel Mejeur, Wesley Hosking, Max Hales, Brian Almeida, Jens Preikschat, Jonas Smedegaard, Robert Lazzurs, Tim Dijkstra, Hari Sundararaghavan, Silas S. Brown, Adrian Chung, Lalit Chhabra, Loic TREGOUET, Sean D. True, Timothy Lee, stripes, David Holland, Sergio Rua, Lee, William X. Walsh,Chris Ham, Angel Luis Jimenez Martinez, James Ascroft-Leigh, Andrea Briganti,cageek, Brad Donison, Jens E. Madsen Jr., Paul Howarth, Gertjan Harkink, Jos De Laender, jdanwhite, and Manoajv Sridhar. gotmail-0.9.0/gotmail0000755000175000017500000013251110545475440013235 0ustar paulpaul#!/usr/bin/perl -w # # GotMail - perl script to get mail from hotmail mailboxes. # Copyright (C) 2000-2003 Peter Hawkins # Copyright (C) 2005 Jon Phillips # Copyright (C) 2005 Michael Ziegler. # Copyright (C) 2005-2006 Jos De Laender # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # # ----------------------------------------------------------------------- # # Currently maintained by Jon Phillips and # John Fruetel # # Peter Hawkins and Paul Cannon are no longer involved with the # development of this software. # require 5.004; eval "use Mail::SpamAssassin;"; # Currently maintained by Jon Phillips and # John Fruetel # # Peter Hawkins and Paul Cannon are no longer involved with the # development of this software. # use English; use URI::Escape; use POSIX qw(tmpnam); use FileHandle; use strict; # Signal handlers: $SIG{INT} = $SIG{TERM} = sub { my($text) = @_; print STDERR "gotmail died with message: $text\n"; print STDERR "Exiting abnormally, cleaning temp files.\n"; doCleanTempFiles(); exit(1); }; # Hide command line in a "ps" listing; $0 = '[ gotmail getting new messages ]'; # This is not great security. The command line can still be found by other # users. I recommend using a ~/.gotmailrc file, so that curl will be passed # the username and password via private temporary files. # Don't allow others to read our temp files my($oldumask) = umask(077); # Constants... my($tmp_headers) = tmpnam()."gotmail_headers".$$; my($tmp_cookies) = tmpnam()."gotmail_cookies".$$; my($tmp_formdata) = tmpnam()."gotmail_form".$$; my($tmp_curl_stderr) = tmpnam()."gotmail_curlstderr".$$; # use constant 0.9.0 => "CVS (Run make)"; my($gotmail_version) = "0.9.0"; # hack to get in version number my($gotmail_date) = "2005-06-16"; # JDLA # Language constants as function of the language code my $current_language = "EN" ; # English is of course (duh) the default. my %lc_trashcan = ( 'DA' => 'Papirkurv', # Dansk, Danish 'DE' => 'Gelschte Nachrichten', # Deutsch, German 'EN' => 'Trash Can', # English, English 'ES' => 'Papelera', # Espaol, Spanish 'FR' => 'Messages supprims', # Franais, French 'IT' => 'Cestino', # Italiano, Italian 'NL' => 'Prullenbak', # Nederlands, Dutch 'NO' => 'Papirkurv', # Norsk, Norwegian 'BR' => 'Lixeira', # Portugus, Portuguese (Brasil) 'FI' => 'Roskakori', # Suomi, Finnish 'SV' => 'Papperskorgen' # Svenska, Swedish ); my %lc_nextpage = ( 'DA' => 'Nste side', # Dansk, Danish 'DE' => 'Nchste Seite', # Deutsch, German 'EN' => 'Next Page', # English, English 'ES' => 'Pgina siguiente', # Espaol, Spanish 'FR' => 'Page suivante', # Franais, French 'IT' => 'Pagina successiva', # Italiano, Italian 'NL' => 'Volgende', # Nederlands, Dutch 'NO' => 'Neste side', # Norsk, Norwegian 'BR' => 'Prxima pgina', # Portugus, Portuguese (Brasil) 'FI' => 'Seuraava sivu', # Suomi, Finnish 'SV' => 'Nsta sida' # Svenska, Swedish ); # If need more system types then add as more integers use constant OS_TYPE_UNIX => 0; use constant OS_TYPE_WIN32 => 1; # default os is unix...but this is checked with the function doCheckOS() my($os_type) = OS_TYPE_UNIX; # 0 will be the default for hotmail.com my(@domains) = ("hotmail.com", "msn.com", "charter.com", "compaq.net", "hotmail.co.jp", "hotmail.co.uk", "hotmail.de", "hotmail.fr", "hotmail.it", "messengeruser.com", "passport.com", "webtv.net"); # Some option dependent variables my($conf_proxy)=""; my($conf_proxy_auth)=""; my($login) = ""; my($password) = ""; my($domain) = 'hotmail.com'; my($resend_address) = ""; my($conf_file) = ""; my(@conf_exclude_folders) = (); my(@conf_folders) = (); my($conf_folder_directory) = ""; my($conf_only_get_new_messages) = 0; my($conf_mark_messages_as_read) = 0; my($conf_delete_messages_after_download) = 0; my($conf_move_messages_after_download) = ""; my($conf_sendmail) = ""; my($conf_curl) = 'curl -k'; my($conf_speed_limit) = 0; my($conf_retry_limit) = 2; my($conf_verbosity) = -1; # -1 = silent; 0 = normal; 1 = verbose; my($conf_save_to_login) = 0; # 0 = no, 1 = yes my($conf_procmail) = 0; # 0 = no, 1 = yes my($conf_sa) = 0; # 0 = no, 1 = yes my($conf_onlyspamscan) = 0; # 0 = no, 1 = yes my($conf_deletespam) = 0; # 0 = no, 1 = yes my($conf_movespam) = ""; my($conf_spamscore) = 4.5; my($conf_procmail_bin) = '/usr/bin/procmail'; my($conf_summary) = 0; my($conf_procmail_option)= ""; my($conf_remove_header) = 0; # 0 = no, 1 = yes my($conf_downloaded) = ""; # JDLA : local file with downloaded messages. my($conf_smtpserver); my($conf_debug) = 0; # Global variables... my($host) = ""; # The name of the hotmail server we are talking to... my($gotconfig) = 0; # Have we found a config file? my(@cookies) = (); my($spam_folder_id) = ""; # Id of the folder where we want to move spam my($move_folder_id) = ""; # Id of the folder where we want to move mail my($trashFolder) = ""; # Id of the trash can folder # Display some text. # First parameter : text to be displayed. # Then a number of named parameters that are optional. # See %args. sub dispText($%) { my $text = shift; my %args = (only_if_interactive => 0, only_if_debug => 0, min_verbosity => 0, stderr => 0, @_); # stderr messages are under no circumstances suppressed. if ($args{'stderr'}) { print STDERR $text; return; } # stdout message at this point. # Filter out the ones for which the verbosity is too high. return if ($args{'min_verbosity'} > $conf_verbosity); # Filter out the debug only messages. return if ($args{'only_if_debug'} && (not $conf_debug) ); # Filter out the interactive only messages. return if ($args{'only_if_interactive'} && (not -t STDOUT) ); # And finally print ;-) print STDOUT $text; return; } # Display summary to the screen, and log it, if we are specified summary. sub dispSummary($) { if ($conf_summary) { my($text) = @_; dispText($text,only_if_interactive=>1); dispText($text,min_verbosity=>2); } } # Various utility functions # Can take the stderr parameter. sub dispIntroText(%) { my %args = (stderr=>0,@_); my $text = "\n". "Gotmail v".$gotmail_version." Copyright (C) 2000-2003 Peter Hawkins\n". "Gotmail comes with ABSOLUTELY NO WARRANTY.\n". "This is free software, and you are welcome to redistribute it\n". "under certain conditions; see the file COPYING for details.\n\n". 'CVS ident: $Id: gotmail.in 112 2006-07-17 13:05:43Z kartar $' . "\n\n". "Running at ".localtime(time)." for user $login\n\n"; dispText($text,%args); } sub dispVersionText() { my $text = "Version information: Gotmail v ". $gotmail_version. " Date: ". $gotmail_date. "\n"; dispText($text,min_verbosity=>-1); } # # JDLA : This hash of arrays describes the options. # The key is the canonical option name as used on command line or # in configuration file. # The value is an array with three entries : # - Symbolic name for parameter of the configuration item. "" if none. # - Subroutine to be called when having detected this option. The value # of the parameter is the argument of the subroutine. # - An explanation that describes the argument (and used for showing the # usage) # # my %options = ( 'usage' => ["",\&dispUsageAndExit, "Display this screen"], 'version' => ["",\&dispVersionText, "Display version information"], 'config-file' => ["",sub {}, "Specify config file. Defaults to ~/.gotmailrc ."], 'username' => ["",sub {$login = shift;}, "Specify your hotmail username (REQUIRED)"], 'password' => ["",sub {$password = shift;}, "Specify your hotmail password (REQUIRED)"], 'domain' => ["",sub {$domain = shift;}, "Specify your domain"], 'proxy' => ["",sub {$conf_proxy = shift;}, "Specify an HTTP proxy to use in host:port format."], 'proxy-auth' => ["",sub {$conf_proxy_auth = shift;}, "Specify authentication details for the HTTP proxy."], 'smtpserver' => ["",sub {$conf_smtpserver = shift;}, "Specify SMTP server. Will not use sendmail."], 'forwarding-email' => ["
",sub {$resend_address = shift;}, "Specify an email address to forward to. Otherwise saved to disk."], 'exclude-folders' => ["\"folders\"", sub { my $arg = shift; @conf_exclude_folders = map { s/^"|"$//g; # Remove leading, trailing quotes. s/^\s+|\s+$//g; # Remove leading, trailing whitespace. $_; # The last value in the map{} construct is its return value. } split(/,/, $arg); # Split on commas. }, "Do not get these folders (listed in quotes as in \"Inbox, Bulk Mail\")"], 'folders' => ["\"folders\"", sub { my $arg = shift; @conf_folders = map { s/^"|"$//g; # Remove leading, trailing quotes. s/^\s+|\s+$//g; # Remove leading, trailing whitespace. $_; # The last value in the map{} construct is placed in @conf_folders } split(/,/, $arg); # Split on commas. }, "Only get these folders (optionally listed in quotes as in \"Inbox, Bulk Mail\")"], 'folder-directory' => ["/my/dir",sub {$conf_folder_directory = shift;}, "Download messages in this directory"], 'downloaded' => ["",sub {$conf_downloaded = shift;}, "Local database of downloaded messages"], 'only-new' => ["",sub {$conf_only_get_new_messages = 1;}, "Only unread messages will be retrieved"], 'mark-messages-as-read' => ["",sub {$conf_mark_messages_as_read = 1;}, "Messages will be marked as read once downloaded"], 'delete' => ["",sub {$conf_delete_messages_after_download = 1;}, "Messages will be deleted after download"], 'move' => ["",sub {$conf_move_messages_after_download = shift;}, "Messages will be moved to this folder after download"], 'retry-limit' => ["",sub {$conf_retry_limit = shift;}, "Maximum number of attempts to download a message"], 'speed-limit' => ["",sub {$conf_speed_limit = 1;}, "Throttle back rate of giving messages to sendmail"], 'save-to-login' => ["",sub {$conf_save_to_login = 1;}, "Save to folder-dir/username for Inbox and folder-dir/username-foldername for others"], 'use-procmail' => ["",sub {$conf_procmail = 1;}, "Send all messages only to procmail."], 'procmail-bin' => ["",sub {$conf_procmail_bin = shift; $conf_procmail = 1;}, "Use this as procmail. Defaults to /usr/bin/procmail and implies --use-procmail."], 'procmail-option' => ["",sub {$conf_procmail_option = shift;}, "Pass options through to procmail."], 'curl-bin' => ["",sub {$conf_curl = shift;}, "Specify the path to the cURL executable if not in path"], 'silent' => ["",sub {$conf_verbosity = -1;}, "Do not print messages"], 'verbose' => ["",sub {$conf_verbosity = 2;}, "Verbosely print messages"], 'verbosity' => ["",sub {$conf_verbosity = shift;}, "Explicitly specify verbosity level."], 'debug' => ["",sub {$conf_debug = 1; $conf_verbosity=100;}, "Print debug output."], 'use-sa' => ["",sub {$conf_sa = 1;}, "Use SpamAssassin to ignore spam."], 'delete-spam' => ["",sub {$conf_deletespam = 1;}, "Delete spam from server when using SpamAssassin."], 'move-spam' => ["",sub {$conf_movespam = shift;}, "Move spam to this folder."], 'spam-score' => ["",sub {$conf_spamscore =shift;}, "SpamAssassin score that's considerd spam. Defaults to 4.5."], 'onlyspamscan' => ["",sub {$conf_onlyspamscan = 1}, "Only fetch mails for scanning spam. No local saves or distribution."], 'summary' => ["",sub {$conf_summary = 1}, "Print the number of messages received one line per folder"], 'remove-header' => ["",sub {$conf_remove_header = 1;}, "Automatically remove X-Message-Info header to not trigger X_MESSAGE_INFO rule."] ); # Alternative short options (-) on the command line. my %short_options = ( '?' => 'usage', 'c' => 'config-file', 'u' => 'username', 'p' => 'password', 'd' => 'domain', 's' => 'smtpserver', 'f' => 'forwarding-email', 'v' => 'verbose', ); # Alternative names for the options. my %option_aliases = ( 'help' => 'usage', 'user' => 'username', 'pass' => 'password', 'forward' => 'forwarding-email', 'folder_dir' => 'folder-directory', 'folder-dir' => 'folder-directory', 'folder_directory' => 'folder-directory', 'onlynew' => 'only-new', 'mark-read' => 'mark-messages-as-read', 'markread' => 'mark-messages-as-read', 'retrylimit' => 'retry-limit', 'speedlimit' => 'speed-limit', 'nodownload' => 'onlyspamscan', ); # This is only called in error conditions. Output will go to stderr. sub dispUsageAndExit() { dispIntroText(stderr=>1); dispText("Usage:\ngotmail [OPTIONS...]\n". "\nOptions:\n",stderr=>1); my %already_shown_options = (); foreach my $short_option (sort keys %short_options) { my $option = $short_options{$short_option}; my $parameter = $options{$option}[0]; my $explanation = $options{$option}[2]; my $explanation1 = $explanation; my $explanation2 = ""; if (length($explanation)>40) { my $place_to_split = rindex($explanation," ",40); $explanation2 = substr($explanation,$place_to_split+1); $explanation1 = substr($explanation,0,$place_to_split); } my $text = " -$short_option, --$option "; $text .= "$parameter" if $parameter; my $finaltext; if ($explanation2) { $finaltext = sprintf("%-35s%-50s\n%-35s%-50s\n",$text,$explanation1,"",$explanation2); } else { $finaltext = sprintf("%-35s%-50s\n",$text,$explanation1); } dispText($finaltext,stderr=>1); $already_shown_options{$option} = 1; } foreach my $option (sort keys %options) { next if $already_shown_options{$option}; my $parameter = $options{$option}[0]; my $explanation = $options{$option}[2]; my $explanation1 = $explanation; my $explanation2 = ""; if (length($explanation)>40) { my $place_to_split = rindex($explanation," ",40); $explanation2 = substr($explanation,$place_to_split+1); $explanation1 = substr($explanation,0,$place_to_split); } my $text = " --$option "; $text .= "$parameter" if $parameter; my $finaltext; if ($explanation2) { $finaltext = sprintf("%-35s%-50s\n%-35s%-50s\n",$text,$explanation1,"",$explanation2); } else { $finaltext = sprintf("%-35s%-50s\n",$text,$explanation1); } dispText($finaltext,stderr=>1); } exit(1); } # Parse ~/.gotmailrc # # Inserted code to parse ~/.gotmailrc # This *should* hopefully be a little secure than specifying your # username and password on the command line. # parseArgs() is called afterwards, so you can override any settings. # Thanks to Patrick Froede # and also to Tim Dijkstra. -pik- sub parseConfig { if ("@ARGV" =~ /(\s|^)(-c|--config-file)\ ([\w\.~\/\-\@]*)(\s|$)/i) { $conf_file = $3; if (! -r $conf_file) { die "Config file <$conf_file> is not readable!\n"; } } elsif ($ENV{"HOME"}) { $conf_file = $ENV{"HOME"} . "/.gotmailrc"; } else { if ($ENV{"HOMEDRIVE"} && $ENV{"HOMEPATH"} && (-e $ENV{"HOMEDRIVE"} . $ENV{"HOMEPATH"} . ".gotmailrc") ) { # Using w2k environment variables. $conf_file = $ENV{"HOMEDRIVE"} . $ENV{"HOMEPATH"} . ".gotmailrc"; } elsif (-e "/.gotmailrc") { # Try root directory $conf_file = "/.gotmailrc"; } else { # Or try current directory $conf_file = "./.gotmailrc"; } } # Open the config file, otherwise bail out of this subroutine open(RCFILE, $conf_file) || return; # Parse the file while () { my $line = $_; next if ($line =~ /^#/); # Comment. next if ($line =~ /^\s*$/); # Empty line. if (not $line =~ m/^([a-zA-Z0-9-_]+)/) { dispText("Wrong configuration line : '$_'\n",stderr=>1); dispUsageAndExit(); } my $option = $1; if (exists $option_aliases{$option}) { $option = $option_aliases{$option}; } if (not exists $options{$option}) { dispText("Wrong configuration line : '$_' (illegal option)\n",stderr=>1); dispUsageAndExit(); } my $option_value = ""; $line = $'; # The remaining of the line. if ($options{$option}[0]) { # value expected if (not $line =~ m/\s*=\s*\S+/) { dispText("Wrong configuration line : '$_' (no value)\n",stderr=>1); dispUsageAndExit(); } # Remove equals sign and leading, trailing whitespace. $line =~ s/=//; $line =~ s/^\s+|\s+$//g; $option_value = $line; } $options{$option}[1]($option_value); # Call of associated sub. } # Make a note that we obtained some configs from the options file $gotconfig = 1; close(RCFILE); } # Parse the command line sub parseArgs() { # If we have a config file, we don't care if there aren't any arguments... if (!@ARGV && ($gotconfig == 0)) { dispUsageAndExit(); } while(@ARGV) { my($element)=shift(@ARGV); my $option; if ($element =~ /^-([a-zA-Z\?])/) { if (not exists $short_options{$1}) { dispText("Wrong option : '$element'\n",stderr=>1); dispUsageAndExit(); } else { $option = $short_options{$1}; } } elsif ($element =~ /^--(\S+)/) { $option = $1; if (exists $option_aliases{$option}) { $option = $option_aliases{$option}; } if (not exists $options{$option}) { dispText("Wrong option : '$element'\n",stderr=>1); dispUsageAndExit(); } } else { dispText("Wrong option : '$element'\n",stderr=>1); dispUsageAndExit(); } my $option_value = ""; if ($options{$option}[0]) { # value expected $element = shift(@ARGV); if (not $element =~ m/(\S+)/) { dispText("Wrong option : '$element' (no value)\n",stderr=>1); dispUsageAndExit(); } $option_value = $element; } $options{$option}[1]($option_value); # Call of associated sub. } if (($login eq "") || ($password eq "")) { dispText("A username and password are REQUIRED.\n",stderr=>1); dispUsageAndExit(); } if ($login =~ m/@/) { dispText( "The username should not contain a domain such as \@hotmail.com\n". "The latter should be specified with the --domain switch\n" ,stderr=>1); dispUsageAndExit(); } } # Clean up any temporary files sub doCleanTempFiles() { if (-e $tmp_headers) { unlink($tmp_headers) or warn "Could not unlink tmp header: $!\n"; } if (-e $tmp_cookies) { unlink($tmp_cookies) or warn "Could not unlink tmp cookie: $!\n"; } if (-e $tmp_formdata) { unlink($tmp_formdata) or warn "Could not unlink tmp formdata: $!\n"; } if (-e $tmp_curl_stderr) { unlink($tmp_curl_stderr) or warn "Could not unlink tmp curlstderr: $!\n"; } } sub doCleanOtherFiles() { } # Check all the required programs are installed. sub doCheckPrograms() { dispText("System version is: ".$OSNAME."\n",min_verbosity=>2); # $PERL_VERSION and $^V seem to be broken dispText("Perl version is: ".$]."\n",min_verbosity=>2); dispText("Curl version is: ".`$conf_curl --version`."\n",min_verbosity=>2); # Try looking for sendmail in a few common places. $conf_sendmail = "sendmail"; if (-x "/usr/sbin/sendmail") { $conf_sendmail = "/usr/sbin/sendmail"; } elsif (-x "/usr/lib/sendmail") { $conf_sendmail = "/usr/lib/sendmail" } $conf_sendmail .= " -i"; # Make sure procmail is there. if ((! -x $conf_procmail_bin) and $conf_procmail) { die "Procmail binary at \"$conf_procmail_bin\" can't be run. Aborting"; } # If we're doing spam detection, make sure SpamAssassin is installed if ($conf_sa) { eval "use Mail::SpamAssassin;"; if ($@) { die("Spam detection specified but SpamAssassin not installed. Aborting"); } } } # Grep any cookies from the header file into the cookies file. sub parseHeaders() { my $redirector = ""; my($in) = new FileHandle "< $tmp_headers" || return; while (<$in>) { if (m/^Location: (\S+)\s/) { $redirector = $1; } } close($in); return $redirector; } # Fetch a given page using curl # # The parameters taken are the URL, any data to be posted in a POST, # whether we are to follow HTTP redirects, whether we should send and # receive cookies, and whether we should only get the headers for this # page and not the body. sub getPage($$$$$) { my($url, $params, $follow_forward, $cookies, $headers_only) = @_; if ($url =~ m/http:\/\/(\S+?)\//i) { $host = $1; } dispText("FETCH: $url\n",min_verbosity=>2); # Set up the options string... my($options) = ""; if ($conf_proxy) { $options .= "--proxy ". $conf_proxy . " "; } if ($conf_proxy_auth) { $options .= "--proxy-user ". $conf_proxy_auth . " "; } if ($cookies != 0) { $options .= "-b $tmp_cookies -c $tmp_cookies " } # if ($cookies != 0) { $options .= "-b $tmp_cookies " } if ($params ne "") { $options .= "--data \"$params\" " } if ($headers_only) { $options .= "-I " } # Curl is put silent (but with error output) when not interactive or low verbosity. if ( (not -t STDOUT) || ($conf_verbosity <= 1) ) { $options .= "-s -S " } if ($conf_debug) { $options .= "-v " } # Get rid of any trailing space on options.. Just for neatness. $options =~ s/ $//; my($cmdline); # JDLA curl outputs info via stderr. Catched in file and appended # to stdout output in debug mode. if ( OS_TYPE_WIN32 == $os_type ) { $cmdline = "$conf_curl --stderr $tmp_curl_stderr \"$url\" $options -i -m 600 -D $tmp_headers" . " -A \"Mozilla/4.73 [en] (Win98; I)\""; } else { $cmdline = "$conf_curl --stderr $tmp_curl_stderr \'$url\' $options -i -m 600 -D $tmp_headers" . " -A \"Mozilla/4.73 [en] (Win98; I)\""; } dispText("command line: $cmdline\n",only_if_debug=>1); my $tries = 1; my @tmp_page = (); while (!@tmp_page && $tries <= $conf_retry_limit) { dispText("Trying [$tries/$conf_retry_limit]...\n",min_verbosity=>2); $tries++; @tmp_page = `$cmdline`; # Copy output. foreach my $line (@tmp_page) { dispText($line,only_if_debug=>1) }; open (CURL_STDERR,"$tmp_curl_stderr") || die "Could not open $tmp_curl_stderr : $!"; # Copy curl stderr. dispText("\nstderr of curl :\n",only_if_debug=>1); while() { my $line = $_; my $password_to_blank = uri_escape($password, "^A-Za-z"); $line =~ s/$password_to_blank/**PASSWORD**/g; dispText("$line",only_if_debug=>1); } close(CURL_STDERR); } if (!@tmp_page && !$headers_only && $tries >= $conf_retry_limit) { &doCleanTempFiles; die("An error was encountered getting the page. Command was $cmdline"); } my $redir = parseHeaders(); # If we have been asked to follow Location: headers if ($follow_forward) { if ($redir ne "") { if ($redir !~ m/^http.*/i) { if ($url =~ m/(http?:\/\/[^\/]+)\//i) { $redir = $1 . $redir; } } dispText("Following redirect to $redir\n",min_verbosity=>2); return &getPage($redir, "", $follow_forward, $cookies, $headers_only); } } return @tmp_page; } # Do the HotMail login process - log in until we have the URL of the inbox. sub doLogin() { dispText("Getting hotmail index page...\n",min_verbosity=>2); my(@index_page); ## This will have the login page. @index_page = getPage("http://www.hotmail.com/", "", 1, 1, 0); my($page) = join("", @index_page); ## @index_page is now an intermediate page which checks if you ## have javascript enabled or not!! This code invokes the form ## on that page to get you to the login/password page. if($page =~ m//i) { my $action = $4; ## This processing happens only for the "new" hotmail structure. dispText("Processing java check....\n",min_verbosity=>2); my($inp); ## This var will store all the input fields. while($page =~ m/<\s*input\s+.*name=\"(\S+)\"(\s+id="\S+")?\s+value=\"(\S*)\"/) { ## Get rid of the input field we processed. $page = $'; $inp .= "$1=" . uri_escape($3) . "\&"; } ## Get rid of the last "&" $inp =~ s/&$//g; my($FORMFILE) = new FileHandle "> $tmp_formdata" || die "Couldn't open formdata file: $!\n"; print $FORMFILE ("$inp"); close($FORMFILE); my($params) = "\@$tmp_formdata"; ## Hopefully this should get us to the correct index page. @index_page = getPage($action, $params, 1, 1, 0); $page = join "", @index_page; } # Find the form "ACTION" parameter... my($login_script); my($login_new) = 0; # Old - multiple forms for multiple domains if ($page =~ m//i) { $login_script = $1; } # New - heavy javascript elsif ($page =~ m//i) { $login_script = $1; $login_new = 1; } # Very old - simple form elsif ($page =~ m//i) { $login_script = $1; } else { &doCleanTempFiles; die "Page doesn't contain any form action field!\n"; } my($FORMFILE) = new FileHandle "> $tmp_formdata" || die "Couldn't open formdata file: $!\n"; if( $login_new ) { dispText("Using New Login...\n",min_verbosity=>2); ## The actual action of the form is replace by javascript ## (authentication depends on the domain of your user id). ## and arguments are appended in javascript if( $page =~ m/g_DO\["\Q$domain\E"\]\s*=\s*"([^"]+)\"/ ) { $login_script = $1; #dispText( "g_DO=$1\n" ); } if( $page =~ m/g_QS\s*=\s*"([^"]+)\"/ ) { $login_script .= index($login_script,'?') >= 0 ? '&' : '?'; $login_script .= $1; #dispText( "g_QS=$1\n" ); } ## Get (or calculate) the hidden fields of the form my ( $PPFT, $PPSX, $PwdPad ); { if( $page =~ m/<\s*input\s+.*name=\"PPFT\"(\s+id="\S+")?\s+value=\"(\S*)\"/ ) { $PPFT = $2; #dispText( "PPFT=$PPFT\n" ); } if( $page =~ m/<\s*input\s+.*name=\"PPSX\"(\s+id="\S+")?\s+value=\"(\S*)\"/ ) { $PPSX = $2; #dispText( "PPSX=$PPSX\n" ); } { my $Padding = "IfYouAreReadingThisYouHaveTooMuchFreeTime"; $PwdPad = substr( $Padding, 0, length($Padding)-length($password) ); #dispText( "PwdPad=$PwdPad\n" ); } } print $FORMFILE ("PPSX=$PPSX" . "\&PwdPad=$PwdPad" . "\&login=" . uri_escape($login . '@' . $domain, "^A-Za-z") . "\&passwd=" . uri_escape($password, "^A-Za-z") . "\&SI=" . uri_escape( ' Sign In ' ) . "\&LoginOptions=3" . "\&PPFT=" . uri_escape( $PPFT ) ); } else { dispText("Using Old Login...\n",min_verbosity=>2); my($ctnum) = ""; if ($page =~ m/ct=([0-9]+)/i) { $ctnum = uri_escape($1); } print $FORMFILE ("login=" . uri_escape($login, "^A-Za-z") . "\&passwd=" . uri_escape($password, "^A-Za-z") . "\&svc=mail\&mspp_shared=1" . "\&domain=" . uri_escape($domain) . "\&RemoteDAPost=https://login.msnia.passport.com/ppsecure/post.asp" . "\&sec=share\&curmbox=ACTIVE\&js=yes\&_lang=EN" . "\&beta=0\&ishotmail=1\&id=2\&fs=1" . "\&cb=_lang%3dEN%26country%3dUS\&ct=$ctnum"); } close $FORMFILE; my($params) = "\@$tmp_formdata"; dispText("Logging in...\n"); my(@login_page) = getPage($login_script, $params, 1, 1, 0); $page = join "", @login_page; # Find where they are sending us now... my($redirect_location) = ""; # Now not needed per Chris Ebenezer's comments # if ($domain eq 'msn.com') { # if ($page =~ m/Location: (\S+)/i) { # $redirect_location = $1; # } elsif ($page =~ /unavailable/i) { # &doCleanTempFiles; # die("Hotmail is reporting that your account is temporarily " . # "unavailable. Please try again later.\n"); # } # # if ($redirect_location eq "") { # &doCleanTempFiles; # die("Hotmail's page structure has changed! (msncom)\n"); # } # # my(@redirect_page) = getPage($redirect_location, "", 0, 1, 0); # $page = join "", @redirect_page; # } if ($page =~ m/top\.location\.replace\(\"(.*)\"\);/i) { $redirect_location = $1; } elsif ($page =~ m/window\.location\.replace\(\"(.*)\"\);/i) { $redirect_location = $1; } elsif ($page =~ m/meta\s*http-equiv="refresh"\s*content="0;\s*URL=([^"]+)"/i ) { $redirect_location = $1; } if ($redirect_location eq "") { &doCleanTempFiles; die("Hotmail's page structure has changed! (redirloc)\n"); } elsif ($redirect_location =~ /loginerr/i) { &doCleanTempFiles; die("There was an error logging in. Please check that your " . "username and password are correct.\n"); } if ($redirect_location =~ m/http:\/\/([^\/]+)\/(.*)$/i) { $host = $1; } else { &doCleanTempFiles; die ("Could not parse redirect location. This could be caused by " . "selecting the wrong Hotmail domain or by an incorrect password " . "or locked account.\n"); } dispText("Following redirect...\n",min_verbosity=>2); my(@redirect_page) = getPage($redirect_location, "", 0, 1, 0); $page = join "", @redirect_page; # JDLA : $page contains a cookie setting with the language. $page =~ m/^Set-Cookie:.+lang%2c(\w+)%2c/m; $current_language = $1; dispText "Detected language code '$current_language'...\n"; # Find where the inbox is located... my($inbox_location); if ($page =~ m/Location: (\S+)/i) { my $inbox_loc = $1; if ($inbox_loc =~ m/\&RedirectLocation=(http[^\&]+)\&/i) { $inbox_loc = uri_unescape($1); } $inbox_loc =~ /(.+)\/dasp\/ua_info.asp\?pg=browser_limit[^&]*(&.+)/; $inbox_location = "$1\/HoTMail"; } elsif ($page =~ /unavailable/i) { &doCleanTempFiles; die("Hotmail is reporting that your account is temporarily " . "unavailable. Please try again later.\n"); } else { &doCleanTempFiles; die("Hotmail's page structure has changed! (inboxloc)\n"); } dispText("Going to Inbox Page: $inbox_location\n",only_if_debug=>1); getPage($inbox_location, "", 1, 1, 0); dispText("Got inbox location...\n"); return $inbox_location; } sub doSaveEmail($$) { my ($output, $email) = @_; # restore umask to whatever user had before umask($oldumask); my($OUT) = new FileHandle ">> $output"; if (! defined ($OUT)) { die("Unable to open $output."); } print $OUT "$email\n"; $OUT->close(); } sub doResendEmail($$) { my($destaddr, $email) = @_; my($OUT) = new FileHandle "| $conf_sendmail $destaddr"; if (! defined ($OUT)) { die("Unable to open sendmail - was using $conf_sendmail $destaddr."); } # Dump the message to sendmail. if ($] >= 8.0) { # $] is the current perl version ### try and stop the Wide Character warnings binmode $OUT, ":utf8"; } print $OUT $email; $OUT->close(); if ($conf_speed_limit) { sleep(1); } } sub doResendSMTPEmail($$$) { use Net::SMTP; my($destaddr, $email, $server) = @_; my $from = "$login\@$domain"; if ($email =~ s/^From ([^ ]*).*\n//) { $from = $1; } dispText("Forwarding email to $destaddr by SMTP\n"); my $smtp_debug = 0; if ($conf_verbosity == 2) { $smtp_debug = 1; } my $mail = Net::SMTP->new($server, Debug => $smtp_debug) or die "Could not connect to SMTP server $server. $!\n"; $mail->mail($from); $mail->recipient($destaddr); $mail->data($email); $mail->quit(); if ($conf_speed_limit) { sleep(1); } } # Return the email message. Actually, it returns two versions # of the message, one with headers added and one without sub getEmail($$) { my($url, $folder) = @_; my(@output) = (); dispText("\nGetting email message...\n"); $url = "http://$host/$url\&raw=0"; my(@email_page) = getPage($url, "", 1, 1, 0); my $emailstr = join "", @email_page; if ($emailstr !~ /pre/) { &doCleanTempFiles; die("Unable to download email message - $emailstr\n"); } # Get everything between the
 
tags @email_page = split(/<\/?pre>/, $emailstr); if (@email_page != 3) { &doCleanTempFiles; die("Unable to download email message - $emailstr\n"); } $_ = $email_page[1]; s/^[\s\n]*//s; # Strip any HTML artifacts from the message body. s/<//g; s/"/\"/g; s/&/&/g; # Add some more special headers right before the message body. my($gm_headers) = "X-gotmail-version: $gotmail_version\nX-gotmail-folder: $folder\nX-gotmail-user: $login\n"; s/^$/$gm_headers/m; # Remove X-Message-Info header if specified if ($conf_remove_header) { s/^X-Message-Info: .*?\n//m; } # Make a copy of the message without the extra headers my ($noHeaders) = $_; # We'll try to parse out the envelope sender and date received by # Hotmail. Apparently, those fields are not _always_ added. If we # can't find good data, we'll have to make stuff up. my($from_addr) = "$login\@$domain"; my($from_date) = scalar gmtime; # Strip "From whoever" when found on the first line- the format # is wrong for mbox files anyway. if (s/^From ([^ ]*) [^\n]*\n//s) { $from_addr = $1; } elsif (m/^From:[^<]*<([^>]*)>/m) { $from_addr = $1; } # Apply >From quoting s/^From ([^\n]*)\n/>From $1/gm; # If an mboxheader was desired, make up one if (m/^\t (\w+), (\d+) (\w+) (\d+) (\d+):(\d+):(\d+) ([+-]?.+)/m) { my($dow) = $1; my($mon) = $3; my($dom) = $2; my($hr) = $5; my($min) = $6; my($sec) = $7; my($yr) = $4; my($senttz) = $8; # Put date in mboxheader in UTC time $hr -= $senttz; while ($hr < 0) { $hr += 24; } while ($hr > 23) { $hr -= 24; } $from_date = sprintf ("%s %s %02d %02d:%02d:%02d %d", $dow, $mon, $dom, $hr, $min, $sec, $yr); } # Add an mbox-compatible header s/^/From $from_addr $from_date\n/; return ($_, $noHeaders); } # Get the messages from a folder called $foldername at $url sub getFolder($$) { my($foldername, $url) = @_; # Get the folder in newest first order dispText("\nLoading folder \"$foldername\" ...\n"); # JDLA : language dependent my $nextpage_string = $lc_nextpage{$current_language}; my $page = 1; my $still_a_page_to_go = 1; my $start_line_of_nextpage_search = 0; my @folder = (); while ($still_a_page_to_go) { $still_a_page_to_go = 0; # Get the messages in whatever order Hotmail says we should push @folder,getPage("http://$host/cgi-bin/HoTMaiL?$url\&page=$page", "", 1, 1, 0); for (my $line_nr=$start_line_of_nextpage_search;$line_nr<@folder;$line_nr++) { if ($folder[$line_nr] =~ m/title="$nextpage_string"/) { $start_line_of_nextpage_search = $line_nr + 1; $still_a_page_to_go = 1; $page++; last; } } } # Redo the list on a table row by table row basis # XXX JDLA : I believe loop above and loop below can be # combined to one more efficient. my @messages; # Get everything that looks like a mail link foreach my $f (@folder) { while ($f =~ m/()/i) { push(@messages, $1); $f = $'; } } # For some reason, some mails are listed more than once. # Sort the list of messages, then only do them once # JDLA : according to me this is unnecessary and confuses the newest first order ... # @messages = sort @messages; #my $oldItem = ""; foreach my $item (@messages) { $item =~ m//i; my $msg_url = $1; # Since the folder is in newest first order, if we are only getting # new messages, and this is not a new message, we can stop here. if ($conf_only_get_new_messages && ($item =~ /msgread/i)) { next; } # JDLA # if conf_downloaded, we check via a local database if the message # is not yet downloaded. If so we skip downloading and a bunch of # other stuff that would be useless. my $have_message_already = 0; if ($conf_downloaded) { if ($msg_url =~ m/\?msg=([^&]+)/) { my $id=$1; #print "Id:'$id'\n"; # Look in local database if e have it already. if (-e $conf_downloaded) { open (DOWNLOADED,"$conf_downloaded") || die "Could not open $conf_downloaded : $!"; while(my $tmp_id = ) { chomp ($tmp_id); if ($id eq $tmp_id) { $have_message_already = 1; #print "Have already $id\n"; last; } } close (DOWNLOADED); } # Add it to local database if we don't have it yet. if (not $have_message_already) { # We don't have it yet. Add it to the downloaded. # A bit preliminary but let's take the risk. open (DOWNLOADED,">>$conf_downloaded") || die "Could not open $conf_downloaded : $!"; print DOWNLOADED "$id\n"; close (DOWNLOADED); } } } # if ($conf_downloaded) # JDLA getEmail , provided that have_message_already was not set. my ($Message, $msgNoHeaders); if (not $have_message_already) { ($Message, $msgNoHeaders) =getEmail($msg_url, $foldername); my $message_from = ""; if ($Message =~ m/^From: (.*)$/m) { $message_from = $1; } my $message_subject = ""; if ($Message =~ m/^Subject: (.*)$/m ) { $message_subject = $1; } dispText(" From: '$message_from'\n Subject: '$message_subject'\n", min_verbosity=>1); } # Check for spam, if requested to. Probable SPAMS are # not downloaded # JDLA : Extra check on have_message_already needed, because # in the case we have it already, $Message will be empty ... if ($conf_sa && not $have_message_already) { my $SpamTest = Mail::SpamAssassin -> new(); my $MessageObject = $SpamTest -> check_message_text($Message); my $Score = $MessageObject -> get_hits(); if ($Score > $conf_spamscore) { if ($conf_deletespam) { dispText("Deleting spam...\n"); getPage("http://$host/$msg_url\&_HMaction=MoveTo\&tobox=$trashFolder", "", 1, 1, 1); } elsif ($conf_movespam) { dispText("Moving spam...\n"); getPage("http://$host/$msg_url\&_HMaction=MoveTo\&tobox=$spam_folder_id", "", 1, 1, 1); } else { dispText("Probably spam (score : $Score) : skipping...\n"); } next; } } # If we're just scanning for spam on the server, don't download if ($conf_onlyspamscan) { next; } # JDLA # All of the original code only executed if we do not have yet # the message. if (not $have_message_already) { # Are we resending or saving? if ($conf_procmail) { my($output) = $Message; dispText("Sending mail message to procmail..."); open PR,"|" . $conf_procmail_bin." ".$conf_procmail_option; print PR $output; close PR; dispText("Done.\n"); } elsif ($resend_address eq "") { my($output) = $Message; my($outfile) = "$conf_folder_directory/"; if ($conf_save_to_login) { $outfile .= $login; if ($foldername ne "Inbox") { $outfile .= ("-" . $foldername); } } else { $outfile .= $foldername; } doSaveEmail($outfile, $output); dispText("Saving message to $outfile...\n"); } elsif ($conf_smtpserver) { my($output) = $Message; doResendSMTPEmail($resend_address, $output, $conf_smtpserver); } else { my($output) = $msgNoHeaders; doResendEmail($resend_address, $output); dispText ("Forwarding message to $resend_address\n"); } # JDLA : Marking and deleting now only active if not have_messages_already. # It became too slow for hotmails where the messages stay stored for # longer term. # When consistently used (downloaded and mark_read option) this should # give no difference. if ($conf_mark_messages_as_read) { dispText("Marking message as read...\n"); getPage("http://$host/$msg_url", "", 1, 1, 1); } if ($conf_delete_messages_after_download) { dispText("Deleting message...\n"); getPage("http://$host/$msg_url\&_HMaction=MoveTo\&tobox=$trashFolder", "", 1, 1, 1); } elsif ($conf_move_messages_after_download) { dispText("Moving message...\n"); getPage("http://$host/$msg_url\&_HMaction=MoveTo\&tobox=$move_folder_id", "", 1, 1, 1); } } # if not HaveMessageReadAlready } } # Returns the strange Hotmail 'id' for a folder name sub getFolderId($$$) { my $host = shift; my $folder_index_url = shift; my $folder_name = shift; my @folder_list = getPage("http://$host/cgi-bin/folders?$folder_index_url", "", 1, 1, 0); # Join the page into one big string, and split it into bits that interest us my $onestr = join "", @folder_list; $onestr =~ s/\n/ /g; @folder_list = grep { /]*>]*>|<\/tr>)/, $onestr); $onestr = join "\n", @folder_list; foreach my $item (@folder_list) { if ($item =~ m/([^<]+)<\/a>/) { my($url) = $2; my($name) = $3; if (lc($name) eq lc($folder_name)) { $url =~ m/curmbox=(.*)&/; return($1); } } } } # Get a list of the folders we have to deal with and parse them one by one. sub doGetFolders($) { my($inbox_location) = @_; dispText("Loading main display...\n",min_verbosity=>2); if ($inbox_location !~ m/^http/) { $inbox_location = "http://$host/cgi-bin/".$inbox_location; } my(@inbox_page) = getPage($inbox_location, "", 1, 1, 0); # Ok, we have the location of the inbox. Where's the master list of folders? my($folder_index_url) = ""; foreach my $item (@inbox_page) { if ($item =~ m/$folder_index_url\n",only_if_debug=>1); if ($folder_index_url eq "") { &doCleanTempFiles; die("Could not isolate folder index location\n"); } # JDLA : language dependent my $trashcan_string = $lc_trashcan{$current_language}; # Get the id of the trash can folder $trashFolder=getFolderId($host, $folder_index_url, $trashcan_string); if ($conf_movespam) { # Figure out the ID of the Spam folder $spam_folder_id = getFolderId($host, $folder_index_url, $conf_movespam); dispText("\$spam_folder_id->".$spam_folder_id."\n"); } if ($conf_move_messages_after_download) { # Figure out the ID of the move to folder $move_folder_id = getFolderId($host, $folder_index_url, $conf_move_messages_after_download); dispText("\$move_folder_id->".$move_folder_id."\n"); } # Ok let's get the folder list! dispText("Loading folder list...\n"); my @folder_list = getPage("http://$host/cgi-bin/folders?", "", 1, 1, 0); # Join the page into one big string, and split it into bits that interest us my $onestr = join "", @folder_list; $onestr =~ s/\n/ /g; @folder_list = grep { /]*>]*>|<\/tr>)/, $onestr); foreach my $item (@folder_list) { if ($item =~ m/.*([^<]+)<\/a>.*/i) { my($url) = $1; my($name) = $2; # Establish numbers of new, unread, total mail in box - courtesy # of Jens Preikschat # Establish total size of mail box - may be useful in the future # $item =~ m/(\w+)<\/font><\/td>/; # my($totalSize) = $1; # Establish "total number of messages" and "number of unread messages" # in the folder $item =~ m/(\d+)<\/td>\s*(\d+)<\/td>/; my($totalItems) = $1; my($unreadItems) = $2; if ((!$conf_only_get_new_messages) || ($unreadItems > 0)) { # Check that this actually _is_ a folder name, without any # html tags. Also makes sure we are not getting the trash # (it looks really stupid when we download a message, delete # it, and then download it again from the trash and delete # it into the trash yet again =) if ( (!($name =~ /[<>]/)) && (!($name =~ /$trashcan_string/i)) ) { $" = "~"; if ((!@conf_folders || ("~@conf_folders~" =~ /~$name~/i)) && (!@conf_exclude_folders || !("~@conf_exclude_folders~" =~ /~$name~/i))) { dispText ("\nProcessing Folder: \"" . $name . "\", Total messages: " . $totalItems . ", Unread messages: " . $unreadItems . ".\n"); dispSummary ("Gotmail Messages received for account $login, folder $name: $unreadItems\n"); getFolder($name, $url); } } } } } } # Checks the systems os and then sets this for the script to use if needed # for specific compatiblities on different platforms. # # usage: if ( OS_TYPE_WIN32 == $os_type ) { # This is currently unused. sub doCheckOS () { # DEFAULT is set to OS_TYPE_UNIX, and is why windows is all that is # checked if ( defined($ENV{'OS'}) && $ENV{'OS'} =~ /windows/i ) { $os_type = OS_TYPE_WIN32; } } doCheckOS(); parseConfig(); parseArgs(); dispIntroText(); doCheckPrograms(); doCleanOtherFiles(); my($inbox_location) = doLogin(); doGetFolders($inbox_location); dispText("\nAll done!\n\n"); doCleanTempFiles(); exit(0); # vim:noet:sw=2:ts=2:filetype=perl gotmail-0.9.0/ChangeLog0000644000175000017500000006155310606722246013431 0ustar paulpaul2007-04-11 James Turnbull * gotmail.spec gotmail4evolution * Removed umask and reverted user/group back to root,root * Incremented gotmail.spec to 0.9.0-1 2007-04-10 James Turnbull * Changelog AUTHORS gotmail.man Makefile.dist Makefile * Makefile.dist NEWS PRESSRELEASE gotmail.spec * Combined AUTHORS file and man page and removed AUTHORS file * from package * Updated Makefile and Makefile.dist to remove man page and * AUTHORS file construction * Removed PRESSRELEASE and NEWS code and files from the package * Removed unused gotmail.spec.in file * Fixed timestamp preservation issues in Makefiles using touch -r * Fixed permissions issues with rpmbuild by building directly with spec file * Updated RPM to 0.9.0 2007-04-05 James Turnbull * Changelog gotmail.spec VERSION Makefile gotmail.man AUTHORS: * Further changes for Fedora Extras submission 2006-10-09 James Turnbull * ChangeLog gotmail.spec VERSION Makefile: Further modifications for Fedora Extras submissions including release 0.8.9-1 2006-07-25 James Turnbull * ChangeLog gotmail.spec Makefile.dist: Modified make process and spec file to support Fedora Extras submission. 2006-07-17 James Turnbull * ChangeLog gotmail.in: Added additional text output to redirect error to address feature request #1284375. 2006-05-03 Jon Phillips * gotmail4evolution ChangeLog: updated the script with getopts and cleaned it up overall. 2006-04-23 Jon Phillips * ChangeLog VERSION AUTHORS NEWS.in PRESSRELEASE.in gotmail.in: Fixed gotmail for the latest version and patched it with the new code to fix the hotmail redirect bug. 2006-03-05 Jon Phillips * Changelog VERSION: Updated date error and also VERSION for current working. * PRESSRELEASE.in: Added some new stuff. 2005-02-26 Jon Phillips * ChangeLog PRESSRELEASE.in NEWS.in VERSION README: Updated the files to prep for the next release 0.8.8. * Makefile: Added support for using txt2html to generate html versions of our documentation. Added first implementation of this for the PRESSRELEASE which generates PRESSRELEASE.html. I did not include this in the packaging though because it is primarily for whoever submits the PR for a release. 2006-01-03 Jos De Laender * gotmail.in : Applied patch 1389121 (thanks to 'jdanwhite') 2005-10-23 Jos De Laender * gotmail.in : 1378340 : Allowed empty line in config file. 2005-12-11 Jon Phillips * gotmail.in : Fixed the problem with the --folder-directory option because it doesn't put a trailing slash for a folder. I just added this slash and now it works. * gotmail4evolution: Committed my old crappy script which gets hotmail and then puts in the proper place for evolution to be able to read the mail. Much work still needs to happen on it and its currently not installed at all. * VERSION: Fixed for release. * PRESSRELEASE.in: Fixed version numbers...arg. * PRESSRELEASE.html: Added this file as several sites need html PR. 2005-10-23 Jos De Laender * gotmail.in : Allowed spaces between option '=' value in the config file. Slipped in $Id: ChangeLog 112 2006-07-17 13:05:43Z kartar $ for CVS based identification (I got lost otherwise). 2005-10-22 Jos De Laender * gotmail.in : When downloaded is active, deleting and marking is now restricted to the not yet downloaded ones. (speed) 2005-09-09 Paul Howarth * Makefile Makefile.dist : Functionality split between Makefiles; main Makefile is for building packages, Makefile.dist is for distribution and handles installation None of the .in files are now distributed, so the packages are much cleaner and less wasteful of space Packages are now built in "packages" subdirectory * gotmail.spec.in : Build from bzipped tarball and include PRESSRELEASE * gotmail.1 : Renamed to gotmail.man and used as a source file for generation of gotmail.1(.gz/.bz2) along with AUTHORS 2005-09-03 Jos De Laender * gotmail.in : Fixing a bug that generates warnings in env-less environment , such as when started from startup scripts 2005-09-03 Jos De Laender * gotmail.in : Fixing a bug in the printing of from and subject of a mail. Fixing a bug in the mark read (and some cleaning up around sorting of messages) 2005-08-31 Jos De Laender * gotmail.in : Implementing [ 1256384 ] Get all messages in a folder first, then process them all 2005-08-28 Jos De Laender * gotmail.in : Superficial verbosity change. Implemented the bug part of [ 1256384 ] : Get all messages in a folder first, then process them all Implemented [ 1052736 ] Problem with sendmail and msg containing a single dot line. (bucovina patch) 2005-08-27 Jos De Laender * gotmail.in : -[ 865738 ] Show sender and subject of deleted spam? Implemented. In fact from --verbosity 1 on , sender and subject are always shown. Also some output cleanup and reformattting. - [ 933293 ] Don't include password in debug files by redirecting of curl stderr -> gotmail stdout + filter 2005-08-26 Jos De Laender * gotmail.in : --usage in less funky format but more in columns. --nodownload switch became --onlyspamscan (old one kept for compat) 2005-08-25 Jos De Laender * gotmail.in : [ 1223473 ] 0.84 "Could not parse redirect location" solved by warning for it. 2005-08-25 Jos De Laender * gotmail.in : I reworked thoroughly the options mechanism. All options are now in one place in an hash. Apart from being more structured (so that comand line options and file options are always consistent) it makes it also easier to go further in localization. 2005-08-23 Jos De Laender * gotmail.in : revamped the output according to following principles - no logfile anymore use ./gotmail options > gotmail.log use ./gotmail options | tee gotmail.log - some output makes only sense interactively (detected and filtered) - some output makes only sense when running in debug mode - verbosity level filtering - errors go to stderr 2005-08-22 Jon Phillips * NEWS.in NEWS: Updated news with newest release notes. Removed NEWS and now using NEWS.in because of processing the VERSION adding to it. * VERSION: Changed the version number to 0.8.5. * *: Branched the release: RELEASE_0_8_6_BRANCH * VERSION: Changed the VERSION to 0.8.7CVS * Makefile: added bzip directive. * PRESSRELEASE.in: Added press release file. 2005-08-21 Jon Phillips * gotmail.in: Fixed the lang. formatting of previous De Laender patch. * Makefile: started to add support for deb files. 2005-08-20 Jos De Laender * gotmail.in : Implemented the requests 1243677 and 1068059. It keeps locally track of the downloaded messages in a file specified with the --downloaded switch. This avoids double downloading. 2005-08-18 Jon Phillips * gotmail.in: Added Jos De Laender's patch to do language detection which provides us a way to utilize language dependent features! This fix allows for the trash and other localized items to be found in the script so that non-English users have the same access. He did a great job on this patch! * AUTHORS: Added Jos De Laender's name to the file. 2005-08-15 Paul Howarth * Makefile: Fix "make dist" problem when gotmail.spec not present. * gotmail: Remove from CVS since it's now generated from gotmail.in. Don't include in tarball, but do include in zipfile because Windows users probably won't have sed to generate gotmail from gotmail.in. * README: Added note about .tar.gz and .zip differences. 2005-08-12 Jon Phillips * gotmail.in: Added for processing to add version number to with make. Also made a level of redundancy with a constant so that gotmail.in can be run so that patches can be applied against this. I'm going to remove gotmail from cvs and then use gotmail.in as the specified file. * gotmail: This is probably going to get replaced. I fixed some version printout code. * Makefile: added code to replace version in the script. 2005-08-11 Paul Howarth * gotmail.spec gotmail.spec.in Makefile: gotmail.spec now generated from new file gotmail.spec.in, based on contents of VERSION file. This results in src.rpm packages that are coherent and can be rebuilt outside the gotmail directory without any special parameters being needed. gotmail.spec itself is no longer needed in CVS. CVS version numbers catered for in rpm version/release tags for sane upgrade path. * Makefile: Rationalised so that "make dist" builds all targets, i.e. tarball, zip, rpm and src.rpm. Individual target "tarball" added. RPM targets now result in rpm files in the build directory. 2005-08-10 Jon Phillips * gotmail: fixed order of stripping out html entites so amp is last * Makefile: Removed TODO and added VERSION to dist * TODO: Moved all the todos to the sf.net page. It is better to track them properly rather than have another place to maintain these. * VERSION gotmail.spec gotmail Makefile: Added file VERSION that has the version of gotmail. This way the version only has to change in one place and then if anyone needs it in a file, etc, then just cat it! 2005-07-12 Jon Phillips * gotmail: Turned gotmail to run silent by default. Changed out some redundant code. 2005-07-11 Jon Phillips * gotmail: I added windows compatibility to the script. I also added some code to do OS checking to prepare for possible future differences between systems we might need to account for. Added note on which option (debug) prints to log file as well as to screen. I added two new options: -l, --log and --use-log which then explictly writes a log. One must remember to change the levels of verbosity in output in order to change the verbosity of output in the logfile. * gotmail.spec gotmail Makefile: Changed version num to 0.8.5CVS. * AUTHORS: Added new name to AUTHORS file. * README: Added instructions for using gotmail on Windows. * gotmail.1: Added new options. 2005-06-27 Jon Phillips * Makefile: Started to add a make test mainly to check make settings. 2005-06-21 Paul Howarth * Makefile: Make more packager-friendly by adding DESTDIR support and generally tidying up. Add "rpm", "srpm", and "rpms" targets for building binary RPM, source RPM, or both. * gotmail.spec: Added gotmail.spec for RPM building. * TODO: Add note about version numbers. 2005-06-21 Jon Phillips * gotmail: Merged patch by Jens E. Madsen Jr. to clean up temporary files on exit. Merged another patch by same author that adds --summary option. Patches tweaked by Paul Howarth to apply against current version, as they were originally submitted in April 2004. * gotmail.1: Added --summary option to the manpage. 2005-06-19 Jon Phillips * gotmail: Changed version number to 0.8.5-CVS 2005-06-18 Jon Phillips * Makefile: Fixed Makefile bug with uninstall. Tested the Makefile. * NEWS: Added NEWS file for release notes and news. * Gotmail.1: Added updates to the man page. 2005-06-16 Jon Phillips * gotmail: Added expansion of $HOME from bash to the conf files. * README: Updated the README and cut out various pieces. Added reference to the new AUTHORS file. * Makefile: Made a basic Makefile to make, clean, distclean, make a the distribution tarball (dist), and uninstall on a standard system 2005-06-14 Jon Phillips * gotmail: Merged patch remove-header.patch to add commandline option for removing header. Merged patch to add procmail-option to both the conf and from commandline. Patched patch which adds exclude-folders option for commandline and for the conf. file. Patched fix for moving mail around in the mailboxes. Changed the query string from "move" to the new "MoveTo". Added support for the various domains that are used for hotmail.com accounts: charter.com, compaq.net, hotmail.co.jp, hotmail.co.uk, hotmail.com, hotmail.de, hotmail.fr, hotmail.it, messengeruser.com, msn.com, passport.com, webtv.net. Now a user can input these into the conf file or through the commandline. Also, added a line to usage of sendmail to check perl version and then get rid of wide character warnings that were getting printed. * AUTHORS: Added an authors file to give credit to all those that have contributed to this project. 2005-06-10 Jon Phillips * gotmail: Merged patch to fix current login woes. The patch was provided by user zieglerm and solved current hotmail redirection problems. It needs testing and users need acurrent version. * Changelog: Changed structure of the Changelog as well. gotmail 0.8.2 - 2004-10-10 * Added code to make sure that SpamAssassin is installed when the --use-sa option is used. * delete-spam wasn't working from .gotmailrc. Fixed. * Added support for moving spam to any folder * Added the spam score threshhold to the command line * Changed the deleted folder constant to reflect Hotmail's changes. * Added support for moving mail after downloading * Now look up the ID of the trash can folder instead of using constant (from user patches) * Fix parsing of folder page to get correct total/unread message count (a space was deleted from the html table layout) * Fix parsing of messages within folder. The messages links occur within one line of the hotmail html output, previous code assumed max of one message per line in html. gotmail 0.8.1 - 2003-12-21 * Removed special handling for msn accounts. Apparently, it's no longer needed. * Enabled support for downloading "Sent Messages" and "Drafts". For some unknown reason, those folders can be downloaded now. * Fixed problem where using both --only-new and --delete could cause infinite loops in certain cases * The SpamAssassin options couldn't be specified in the .gotmailrc file; fixed so now they can gotmail 0.8.0 - 2003-12-5 * Many changes to deal with hotmail.com structure change * SpamAssassin options made --use-sa Runs mail against SpamAssassin to check for spam. Doesn't forward or download spam --delete-spam In addition to not downloading spam, delete it. * Added nodownload option --nodownload Don't acutally download messages. Useful when combined with -delete-spam gotmail 0.7.9 - 2003-03-13 * Added check to make sure procmail binary can be found; aborts if not. Previously mail sent to procmail just went nowhere if the procmail wasn't in /usr/bin. * Fixed messages printed when --silent was specified. * Added option to specify path to curl executable. Previously, gotmail would use "./curl" if found, and curl in the path if not. "./curl" will no longer work unless specified explicitly with --curl-bin. The default is still to search the path. * Removed extraneous exit() calls from argument processing. * Fixed --folders option (when specified at the command line, was expecting a "/" separator, while the manpage said to use commas. Behavior now matches manpage; use comma separators. gotmail 0.7.8 - 2003-03-13 * Patch from Lalit Chhabra to fix new hotmail b0rkage * Patch from Chris Ham to stop skipping pages when deleting * Added --procmail-bin option to set procmail's location; /usr/bin/procmail is now only the default. gotmail 0.7.7 - 2003-01-13 * Releasing 0.7.7pre2 gotmail 0.7.7pre2 - 2003-01-10 * Different fix for broken delete action; should work for non-English accounts and the Junk Mail folder gotmail 0.7.7pre1 - 2003-01-09 * Fixed the broken mark-read and delete actions. Hotmail made another change in the folder code a few days ago which broke all versions of Gotmail. gotmail 0.7.6 - 2003-01-08 * Added support for msn.com addresses. Thanks to William X. Walsh, whose patch provided much of the needed additions. gotmail 0.7.5 - 2003-01-04 * Fix backwards logic in the SMTP debugging flag * Fixed output of perl version when debugging ($PERL_VERSION seems to be broken?) * Fix HTML entities _before_ trying to recognize From: headers * When from address can't be determined (because it seems we can't rely on Hotmail to send valid From lines or From: headers), use a valid email address ($login\@hotmail.com) instead of just "Hotmail". This avoids breaking SMTP. * Changed url for deleting messages, so that they are moved correctly into the Trash folder instead of being sent to limbo. gotmail 0.7.5pre3 - 2002-10-23 * Remove -w to avoid getting stupid warnings about "UTF characters" when Hotmail uses Microsoft's 0x95=apostrophe screwy extra characters * Made folder names case-insensitive gotmail 0.7.4 - 2002-10-21 * Unescape cookie values in handler; Microsoft is getting trickier.. * Handle cookies coming from login page as well as others * Patch by Hari changing the login string format * Patch sent by several people fixing the regexp to recognize amounts of total and unread mail * I have a few other patches that add some possibly useful functionality. I'm holding on to these to get this fix out faster. I don't want to add too much until I can get the rewrite done. gotmail 0.7.3 - 2002-07-11 * Added patch by Sergio Rua to introduce the --use-procmail option (sends all messages to procmail) * Print version number to --debug logfile; I get too many reports that include logfiles but not the program output or version information. * Added X-gotmail-user header specifying which Hotmail user received the mail. Patch by David Holland. gotmail 0.7.2 - 2002-06-28 * Trying to keep up with Hotmail's little bitty changes. Mostly just regexp tweaks. gotmail 0.7.1 - 2002-05-16 * Updated copyright dates * Added -i switch to sendmail command to ignore false end-of- transmission (Thanks to Denzil Boyter) * Fixed stupid invalid line in sample gotmailrc ("proxy=no"; removed). Got lots of messages about this! * Incorporated changes from Ivor@ivorp.com to allow Gotmail to work on a Windows system! Adds the --smtpserver option, and the requirement for libnet-perl. * Incorporated changes based on "lorddrumstik"'s patch to allow naming folders based on login name. (--save-to-login option) * Fixed handling of items in folder lists; now doesn't match on substrings. gotmail 0.7.0 - 2002-05-11 * Package adopted by paul cannon (the maintainer of the Gotmail Debian package) after receiving Peter's blessing. He doesn't have the time or the inclination to maintain this software anymore. Thanks for all your work, Peter! * Removed debian subdirectory; it will be confined to the Debian source packages. I plan to release 0.7.0 as an RPM and as a simple tarball as well as a .deb. * Reformatted code somewhat; cosmetic changes, indentation fixes, removed windows-style newlines * Renamed script to simply "gotmail" * Made options in config files match those in the arguments (but the old names will still work) * Incorporated features, fixes, and enhancements from the Debian gotmail package (0.6.6-1 to 0.6.6-7): * Fixed script to understand changes in Hotmail's system. * Don't pass sensitive info to curl on the command line. * Clean up temp files properly on unclean (and clean) exits. * Fixed retry counting. * Redirect only on Location lines in the header, not in the body. * Fixed argument- and config file-processing with better regexps. Long options were being matched as substrings. * Saves to file are now valid mbox files, and can be read in mutt or other mbox-aware MUAs. * Do >From quoting when saving to local mbox files. * Added -c|--config file option to use a different file than the default (~/.gotmailrc). * Added X-gotmail- headers to processed messages. Version 0.6.6 - 2001-07-24 ========================== * Minor update to correct for Hotmail change. Thanks to loic@cri74.org (sorry, I can't spell the french characters in your name!) Version 0.6.5 - 2000-09-22 ========================== * Added support for retrying failed downloads * Changed debian build system to use debhelper Version 0.6.4 - 2000-08-28 ========================== * Multiple bug fixes for change in Hotmail structure. Version 0.6.3 - 2000-08-15 ========================== * Fixed bug with mailbox sort order introduced accidently in 0.6.2 * Small bug fix to make the server blacklist work in certain cases. * Added additional host to blacklist. Version 0.6.2 - 2000-08-11 ========================== * Changed default log file location to /tmp/gotmail_log * Added server blacklist function - work around for the "I can't download mail" bug. * Added information about the mailing list to the README. * Code cleanups Version 0.6.1 - 2000-08-08 ========================== * Fixed a _dumb_ bug which resulted from blindly applying a patch someone else sent me (patch screwed up and applied to the wrong place). * Cleaned up the email message interpretation code * Added a --silent option * Added a --folder-directory option * Made use of temporary files a bit smarter * It should now be possible to run gotmail from within a cron job. Version 0.6 - 2000-07-16 ======================== * Added proxy auth support, thanks to Joel Mejeur * Created a debian package version * Created a manpage to go with the Debian package * Renamed gotmailrc to sample.gotmailrc * Change of email address from peterhawkins@ozemail.com.au to peter@hawkins.emu.id.au Version 0.5 - 2000-04-27 ======================== * Fixed portability problem with superfluous "which" * Added check for the "Your account is temporarily unavailable" message. * Fixed unintentional logfile generation. * Added system version information display to --debug output. * Documentation updates. Version 0.4 - 2000-04-01 ======================== * This program now causes world peace. * Fixed stupid bug with proxy support in config file. * Added option to only download certain folders. * Changed message box format to unix mbox - you can now use gotmail folders in netscape or similar. * Fixed .gotmailrc parsing, thanks to Herman Mereles * Made gotmail much quicker at getting new messages only (Thanks to Kamal Mahyuddin * Rewrote getCookies routine in perl to make it portable. * Added solaris support. Thanks to Kamal Kantawala * Fixed code to work with "use strict"; Version 0.2 - 2000-03-23 ======================== * Option parsing code restructured to make other options possible. (redph0enix@hotmail.com) * --proxy option added to make use of HTTP proxies possible (redph0enix@hotmail.com) * Direct pipe to sendmail now used when resending mail (reph0enix@hotmail.com) * Added the capability to only get unread messages. * Added the capability to mark messages as read. * Added the capability to delete messages after they are downloaded. * Code now cleans up the temporary files. * Added more comments to code. * Various minor cleanups (made more variables local). Version 0.1 - 2000-03-21 ======================== * Initial release. gotmail-0.9.0/README0000644000175000017500000001030010606615047012517 0ustar paulpaulGotmail ======= For the most up to date information, please visit http://gotmail.sf.net/ Original by Peter Hawkins First maintainer Paul Cannon Second Maintainer: John Fruetel Current Maintainer: James Turnbull Description =========== This is Gotmail, a perl script to fetch mail out of your Hotmail or MSN account. This is especially useful if you want to move from Hotmail into one of the other free mail services - one command can do it all. Gotmail also supports getting any new mail only from your Hotmail or MSN account - perfect for using a Hotmail account as a redirect address into another account. Requirements ============ * UNIX/LINUX * Perl 5 * curl 7.9.8 or better * curl-ssl 7.9 or later (ssl is _required_ to use hotmail... ) It's debian package "curl-ssl" for those who are running debian. You can get it from http://curl.haxx.se/ if you aren't. * The URI cpan module (liburi-perl debian package, or http://search.cpan.org/search?dist=URI) * The libnet cpan module (libnet-perl debian package, or http://search.cpan.org/search?dist=libnet) * Windows (WIN32) * Download and Install ActiveState Perl (www.activestate.com) * Downlod and Install the latest curl package for WIN32 from http://curl.haxx.se/ * Download and Install the latests OpenSSL for WIN32 from http://curl.haxx.se/, or an installer from http://www.shininglightpro.com/products/Win32OpenSSL.html * If either or both of the previous packages are simply binaries and not installers, then copy the .exe and .dll files from the uncompressed packages to C:\WINDOWS\system32 * Open a commandline and navigate to where the gotmail script is located. * Run the gotmail script like so: perl gotmail NOTE: Support for Windows is new so please file any bugs or requests at http://gotmail.sf.net/ NOTE: The .tar.gz distribution of gotmail does not include the gotmail program itself - it's generated from gotmail.in using the "sed" editor. Since most Windows users won't have "sed", the .zip distribution of gotmail includes the already-generated gotmail program. Usage ===== If your perl interpreter is not in /usr/bin, you will need to edit the first line of the script to make it point to the correct place, or start the script using /path/to/perl gotmail. If you have your perl modules in an unusual place, you'll need to add the line: use lib 'path/to/my/perl/modules'; to the gotmail script, somewhere near the top. Read the included manpage (gotmail(1)) or try "gotmail --help" for usage instructions. A sample rc file is included called "sample.gotmailrc". Options from the command line will override those from the rc file. NOTE: Windows users, activestate perl has the required perl modules already installed, however if there are any errors, please report as a bug. Notes ===== * Mail in the Trash Can will not be downloaded. This is to avoid downloading two times any mail which is deleted by the script. * If the page structure of HotMail is changed, this script may stop working. If that happens, file a bug so that I'm sure to know about it. Known Issues ============ * Currently, one must include their password inside the configuration file in cleartext for usage with one's hotmail account. This is up to the user to decide on how to use this feature. It is recommended to NOT place a password in cleartext unless this folder is ONLY readable by the user. Another solution is to use an encrypted filesystem. If anyone has a better solution to this issue, please submit a patch. How to report a bug =================== * Go to: http://sourceforge.net/projects/gotmail * Click the bugs menu * File the bug while either logged in or anonymous * Please explain in depth and provide attachments if possible * Include these things: - A brief description of your problem. - Run the script with --debug and send me the output ALONG WITH the "/tmp/gotmail_log" file generated by the script. - Your ~/.gotmailrc file, if you use one. Authors ======= * Please see the man page to see all the people that have contributed to Gotmail over the years. gotmail-0.9.0/sample.gotmailrc0000644000175000017500000000053610545475440015040 0ustar paulpaul# This is a sample gotmail configuration file. Rename it to .gotmailrc # and place it in your home directory to use it. # See the manpage for more options! username=username password=password domain=hotmail.com forward=forward@to.my.email.address save-to-login only-new # folder-dir=/home/joe/mail # folders=Inbox, Different Folder retry-limit=3 gotmail-0.9.0/gotmail4evolution0000644000175000017500000001141510545475440015262 0ustar paulpaul#!/bin/bash # # gotmail4evolution - gets hotmail and makes ready for evolution. # # Copyright (C) 2005 Jon Phillips # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # # # # This is an ugly script to get hotmail email and put them in the proper # place by force to be used inside Evolution # # # INSTALL NOTE: Put this into you local scripts directory like: # # ~/bin # # After that, then run on your own evolution folder. # # # TODO: Make this work for multiple non-hotmail.com domains # TODO: Make this work for more than Inbox and Junk Mail folders. # TODO: Do file tests. # # # for debugging VERBOSE= #MAILPATH="" MAILPATH="$HOME/.evolution/mail/local" USERNAME= PASSWORD= GOTMAIL=gotmail test_ret_val () { # arg 1 is error code and optional arg 2 is message indicating error if [ $1 != 0 ] then : if [ "$2" ] then : echo $2 else : echo "There seemed to be a problem with the script (error code $1)." fi echo "" exit 1 fi #fi } # proc_mbox () # # This sub processes a passed old mbox and moves to the proper location. # proc_mbox () { # $1 is tmp box and $2 is new box if [ -z "$1" ] && [ -z "$2" ] then : # echo "$1 $2" #echo "You must provide username and password for accounts" return 1 else : # Process vars if [ -e "$1" ] # if the mbox exists then : cat "$1" >> "$2" chmod 600 "$1" chmod 600 "$2" fi fi return 0 } # # getMyHotmail () # # This sub uses the gotmail script to get my two main hotmail accounts # get_my_hotmail () { # $1 is username and $2 is password if [ -z "$1" ] && [ -z "$2" ] # if [ $1 ] then : echo "$1 $2" #echo "You must provide username and password for accounts" #return 1 else : #OLD: MAILPATH="$HOME/evolution/local/$1@hotmail.com" TMP_PATH="/tmp/$1@hotmail.com" INBOX="$MAILPATH/$1@hotmail.com" JUNKMAIL="$INBOX.sbd/Junk" # If it doesn't exist, then create, otherwise clear out the stuff in it if [ ! -e "$TMP_PATH" ] # if it doesn't exist then : mkdir $TMP_PATH else : rm -Rf $TMP_PATH/* fi RETURN=$? test_ret_val "$RETURN" if [ ! -z $VERBOSE ]; then VERBOSECMD="-v" fi $GOTMAIL -u $1 -p $2 --folder-dir $TMP_PATH --mark-messages-as-read \ --delete $VERBOSECMD RETURN=$? test_ret_val "$RETURN" # deal with proc_mbox "$TMP_PATH/Inbox" "$INBOX" RETURN=$? test_ret_val "$RETURN" proc_mbox "$TMP_PATH/Junk E-Mail" "$JUNKMAIL" RETURN=$? test_ret_val "$RETURN" fi return 0 } print_help () { echo -e "\nGets hotmail and puts it somewhere evolution can see it." echo -e "\nUSAGE:\n`basename $0` [-hqv] [-u USERNAME ] [-p PASSWORD]" \ " [-m PATH_TO_EVO_MAIL]\n" echo -e "\t-h help" echo -e "\t-v verbose output" echo -e "\t-q quiet output" echo -e "\t-u username" echo -e "\t-p password" echo -e "\t-m path to evolution mail\n" exit 1 } # This is the main driver code # First need to check if we are online and getting hotmail.com # # ping -c 1 hotmail.com # RETURN=$? # test_ret_val "$RETURN" "Your Internet connection or hotmail.com is offline." ############################################################################### # MAIN DRIVER CODE ############################################################################### # deal with commandline args (a : at the beginning suppresses some errors) # put the : after a flag to grab next parameter as option while getopts "hvqu:p:m" flag do # echo "$flag" $OPTIND $OPTARG case "$flag" in v) VERBOSE=1;; q) VERBOSE=;; u) USERNAME="$OPTARG";; p) PASSWORD="$OPTARG";; m) MAILPATH="$OPTARG";; h) print_help;; \? ) print_help;; * ) print_help;; esac done # if no arguments, then do this (don't need currently) #if [ "$#" == 0 ] #then : # print_help if [ -z $USERNAME ] && [ -z $PASSWORD ] then : echo $USERNAME echo $PASSWORD print_help fi get_my_hotmail $USERNAME $PASSWORD exit 0