24.07.2017 Views

Hacking Gmail

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Chapter 7 — <strong>Gmail</strong> Libraries<br />

131<br />

Function<br />

What It Does<br />

send_message( to => Sends a message to a single recipient.<br />

‘user@domain.com’, To send to multiple users, send an arrayref containing all of the<br />

subject => ‘Test Message’, users:<br />

msgbody => ‘This is<br />

a test.’ );<br />

my $email_addrs = [<br />

‘user1@domain.com’,<br />

‘user2@domain.com’,<br />

‘user3@domain.com’, ];<br />

$gmail->send_message( to => $email_addrs,<br />

subject => ‘Test Message’, msgbody => ‘This is a<br />

test.’ );<br />

send_message( to => Sends a message with an attachment.<br />

‘user@domain.com’,<br />

subject => ‘Test Message’,<br />

msgbody => ‘This is a<br />

test.’, file0 => [“/tmp/<br />

foo”], file1 => [“/tmp/<br />

bar”] );<br />

delete_message<br />

( msgid => $msgid, del_<br />

message => 0 );<br />

delete_message( msgid =><br />

$msgid );<br />

Sends a message to the Trash.<br />

Permanently deletes the message.<br />

The rest of this module is covered in Chapter 8 onwards.<br />

Python — Libgmail<br />

The trifecta of scripting languages beginning with P ends with ython, and is completed<br />

by Libgmail, the Python bindings for <strong>Gmail</strong> access.<br />

Getting and Installing the Library<br />

Libgmail is hosted on Sourceforge at http://Libgmail.sourceforge.net/<br />

and can be downloaded directly from there. The authors of Libgmail advise using<br />

the version from CVS if possible, as it is more likely to work with whatever<br />

changes Google has made to the service lately. Figure 7-3 gives the traditional<br />

screenshot of the project’s homepage.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!