Skip to content

Instantly share code, notes, and snippets.



Created Nov 14, 2012
What would you like to do?
Nexus 4 availability email script (using sendmail)
from urllib import urlopen
import smtplib
import logging
import os
sender = ''
recipients = [''
#add more here
subject = 'Nexus 4 back in stock!?'
body = """
Check Google Play US Store!
You are receiving this email since you signed up for an alert from my experimental script.
If this message reaches on time, drop me a comment on and make my day!
If it doesn't.. errr.. oops. I tried. ^_^
Rishab Arora
contents = urlopen("").read()
if contents.find("buy-hardware-button") != -1: #Page doesn't say Sold Out anymore!
message = "\r\n".join(["From: " + sender,
"Subject: " + subject,
"Bcc: " + ", ".join(recipients),
"MIME-Version: 1.0",
"Content-Type: text/plain",
SENDMAIL = "/usr/sbin/sendmail" # sendmail location
#more likely to end up in spam for me
p = os.popen("%s -t -i" % SENDMAIL, "w")
status = p.close()
if status:
print "Sendmail exit status", status
except Exception:
print logging.exception('')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment