NAME

App::wsgetmail::MS365 - Fetch mail from Microsoft 365

SYNOPSIS

my $ms365 = App::wsgetmail::MS365->new({
  client_id => "client UUID",
  tenant_id => "tenant UUID",
  secret => "random secret token",
  global_access => 1,
  folder => "Inbox",
  post_fetch_action => "mark_message_as_read",
  debug => 0,
})

DESCRIPTION

Moo class providing methods to connect to and fetch mail from Microsoft 365 mailboxes using the Graph REST API.

ATTRIBUTES

You must provide client_id, tenant_id, post_fetch_action, and authentication details. If global_access is false (the default), you must provide username and user_password. If you set global_access to a true value, you must provide secret.

client_id

A string with the UUID of the client application to use for authentication.

tenant_id

A string with the UUID of your Microsoft 365 tenant to use for authentication.

username

A string with a username email address. If global_access is false (the default), the client authenticates with this username. If global_access is true, the client accesses this user's mailboxes.

user_password

A string with the user password to use for authentication without global access.

folder

A string with the name of the email folder to read. Default "Inbox".

global_access

A boolean. If false (the default), the client will authenticate using username and user_password. If true, the client will authenticate using its secret token.

secret

A string with the client secret to use for global authentication. This should look like a long string of completely random characters, not a UUID or other recognizable format.

post_fetch_action

A string with the name of a method to call after reading a message. You probably want to pass either "mark_message_as_read" or "delete_message". In principle, you can pass the name of any method that accepts a message ID string argument.

stripcr

A boolean. If true, the message content will have CRLF line terminators converted to LF line terminators.

debug

A boolean. If true, the object will issue a warning with details about each request it issues.

METHODS

new

Class constructor method, returns new App::wsgetmail::MS365 object

get_next_message

Object method, returns the next message as an App::wsgetmail::MS365::Message object if there is one.

Will lazily fetch messages until the list is exhausted.

get_message_mime_content

Object method, takes message id and returns filename of fetched raw mime file for that message.

delete_message

Object method, takes message id and deletes that message from the outlook365 mailbox

mark_message_as_read

Object method, takes message id and marks that message as read in the outlook365 mailbox

get_folder_details

Object method, returns hashref of details of the configured mailbox folder.

AUTHOR

Best Practical Solutions, LLC <modules@bestpractical.com>

LICENSE AND COPYRIGHT

This software is Copyright (c) 2020 by Best Practical Solutions, LLC.

This is free software, licensed under:

The GNU General Public License, Version 2, June 1991