Skip to content

Instantly share code, notes, and snippets.

@Dewep
Created July 28, 2015 13:06
Show Gist options
  • Save Dewep/bf610dcd45dcabfdc38e to your computer and use it in GitHub Desktop.
Save Dewep/bf610dcd45dcabfdc38e to your computer and use it in GitHub Desktop.
Test preload image Google
#> python send_email.py
#> python server.py
Serving HTTP on 0.0.0.0 port 8000 ...
*************
Host: my-server.com:8000
Connection: Keep-alive
Accept-Encoding: gzip,deflate
User-Agent: Mozilla/5.0 (Windows NT 5.1; rv:11.0) Gecko Firefox/11.0 (via ggpht.com GoogleImageProxy)
*************
66.249.93.185 - - [28/Jul/2015 14:57:12] "GET /image.png HTTP/1.1" 200 -

This request was done only after that I clicked on Show pictures.

import smtplib
e_from = "yyyyyyyyyy <[email protected]>"
e_to = "xxxxxxxxx <[email protected]>"
message = "From: " + e_from + "\nTo: " + e_to + """
MIME-Version: 1.0
Content-type: text/html
Subject: test html
This is a <b>html</b> test e-mail message.
Test image:
<img src='http://my-server.com:8000/image.png'/>
"""
smtp = smtplib.SMTP('smtp.laposte.net', 25)
smtp.starttls()
smtp.login("[email protected]", "my-password")
smtp.sendmail(e_from, [e_to], message)
smtp.close()
import sys
import BaseHTTPServer
from BaseHTTPServer import BaseHTTPRequestHandler
class HandlerClass(BaseHTTPRequestHandler):
def do_GET(self):
print("*************")
print(str(self.headers))
print("*************")
self.send_response(200)
self.send_header('Content-type', 'image/png')
self.end_headers()
with open("image.png", 'rb') as content:
self.wfile.write(content.read())
HandlerClass.protocol_version = "HTTP/1.0"
httpd = BaseHTTPServer.HTTPServer(('0.0.0.0', 8000), HandlerClass)
sa = httpd.socket.getsockname()
print("Serving HTTP on", sa[0], "port", sa[1], "...")
httpd.serve_forever()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment