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.

166 Part II — Getting Inside <strong>Gmail</strong><br />

); # we are using sender and subject from the<br />

original message<br />

print “message sent\n”;<br />

}<br />

This is, of course, an extremely simple script and well positioned to be built upon.<br />

Sending Attachments<br />

To attach files to a message via the WWW::Webmail::<strong>Gmail</strong> module, you only<br />

need use the send_message function as normal, but provide a file reference to the<br />

attachment. Because you’re programmers, remember, you start counting from zero.<br />

So the first reference is file0, the second file1, and so on. Like so:<br />

$gmail->send_message(<br />

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

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

msgbody => ‘This is a test.’,<br />

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

file1 => [“/tmp/bar”]<br />

);<br />

And Now . . .<br />

So, in this short chapter, you learned how to send mail. In the next chapter, you<br />

look at the much more advanced concepts of organizing your mail inside <strong>Gmail</strong>,<br />

programmatically. This will allow you to go on and use <strong>Gmail</strong> for more complicated<br />

applications.

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

Saved successfully!

Ooh no, something went wrong!