Hacking Gmail

(Grace) #1

166 Part II — Getting Inside Gmail


); # we are using sender and subject from the
original message
print “message sent\n”;
}

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

Sending Attachments
To attach files to a message via the WWW::Webmail::Gmail module, you only
need use the send_messagefunction as normal, but provide a file reference to the
attachment. Because you’re programmers, remember, you start counting from zero.
So the first reference is file0, the second file1, and so on. Like so:
$gmail->send_message(
to => ‘[email protected]’,
subject => ‘Test Message’,
msgbody => ‘This is a test.’,
file0 => [“/tmp/foo”],
file1 => [“/tmp/bar”]
);

And Now...


So, in this short chapter, you learned how to send mail. In the next chapter, you
look at the much more advanced concepts of organizing your mail inside Gmail,
programmatically. This will allow you to go on and use Gmail for more compli-
cated applications.
Free download pdf