The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.


WWW::Hotmail - Connect to Hotmail, download, delete and send messages


  use WWW::Hotmail;
  my $hotmail = WWW::Hotmail->new();
  $hotmail->login('', "bar")
   or die $WWW::Hotmail::errstr;
  my @msgs = $hotmail->messages();
  die $WWW::Hotmail::errstr if ($!);

  print "You have ".scalar(@msgs)." messages\n";

  for (@msgs) {
        print "messge from ".$_->from."\n";
        # retrieve the message from hotmail
        my $mail = $_->retrieve;
        # deliver it locally
        # forward the message
        # delete it from the inbox
    to      => ['',''],
    subject => 'Hello Person!',
    body    => q[Dear Person,
  I am writing today to tell you about something important.

  Thanks for all your support.
  Other Person
  ]) or die $WWW::Hotmail::errstr;


This module is a partial replacement for the gotmail script (, so if this doesn't do what you want, try that instead.

Create a new WWW::Hotmail object with new, and then log in with your MSN username and password with the login method.



Make sure to add the domain to your username, for example Then this will allow you to use the messages method to look at the mail in your inbox. The login method does not retrieve messages on login. The messages method does that now.


This method returns a list of WWW::Hotmail::Messages; each message supports four methods: subject gives you the subject of the email, just because it was stunningly easy to implement. retrieve retrieves an email into a Mail::Audit object - see Mail::Audit for more details. from gives you the from field. Finally delete moves it to your trash.


You can use the compose message to send a message through the account you are currently logged in to. You should be able to use this method as many times and as often as you like during the life of the WWW::Hotmail object. As its argument, it takes a hash whose keys are to, cc, bcc, subject, body. Newlines should work fine in the body argument. Any field can be an array; it will be joined with a comma. This function returns 1 on success and undef on failure. Check $WWW::Hotmail::errstr for errors, or use $WWW::Hotmail::errhtml for an html version of the error.


This module used to croak errors for you. If you would like this behavior, then add $WWW::Hotmail::croak_on_error = 1; to your script. It will not croak html.

This module should work with email addresses at,,,,, and

This module is reasonably fragile. It seems to work, but I haven't tested edge cases. If it breaks, you get to keep both pieces. I hope to improve it in the future, but this is enough for release.


WWW::Mechanize, Mail::Audit, gotmail


David Davis, <> - I've taken ownership of this module, please direct all questions to me.


Simon Cozens, <>


David M. Bradford <> - Added the ability to send messages via hotmail.


Copyright 2003-2004 by Kasei Copyright 2004 by David Davis

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.