24.07.2017 Views

Hacking Gmail

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Sending Mail<br />

chapter<br />

Now that you know how to read the mail in your Inbox<br />

with your own programs, it’s time to move on to replying<br />

to those mails by sending your own messages.<br />

Sending Mail with <strong>Gmail</strong> SMTP<br />

The first thing to remember is that <strong>Gmail</strong> provides its own SMTP<br />

server. This offers two major features. First, you can use the SMTP<br />

server from your own e-mail application, which is a great help if<br />

you’re traveling and your usual e-mail provider is unreachable. The<br />

second use is that every single scripting language you might have a<br />

desire to use has standard SMTP support available as a library, and<br />

the support for TLS encryption, which you need to connect to<br />

<strong>Gmail</strong>, is being added apace.<br />

First, though, the settings you’ll need:<br />

Server name: smtp.google.com<br />

Username: yourgmailname@gmail.com<br />

Password: Your <strong>Gmail</strong> password<br />

Security: Yes, using TLS<br />

in this chapter<br />

˛ Using the <strong>Gmail</strong><br />

SMTP server<br />

˛ Sending mail<br />

with Perl<br />

˛ Replying to<br />

mail with Perl<br />

One thing to note about this technique is that <strong>Gmail</strong> will rewrite<br />

your e-mail headers. It replaces the From: and Reply-to: lines<br />

with your <strong>Gmail</strong> address because <strong>Gmail</strong> also automatically adds<br />

the so-called Domain Keys to their outgoing e-mails, allowing<br />

spam-hit system administrators to block fake <strong>Gmail</strong> mail from<br />

their servers. Without the Domain Keys this wouldn’t work, but<br />

<strong>Gmail</strong> can’t send mail with a different From: or Reply-to: address<br />

without breaking the Domain Key.

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

Saved successfully!

Ooh no, something went wrong!