Skip to content

Instantly share code, notes, and snippets.

@lionelyoung
Created February 6, 2014 10:30
Show Gist options
  • Save lionelyoung/8841772 to your computer and use it in GitHub Desktop.
Save lionelyoung/8841772 to your computer and use it in GitHub Desktop.
import xmlrpclib, webbrowser
# EDIT: webfaction credentials
username = "USERNAME"
password = "PASSWORD"
# EDIT: email address domain (must exist in control panel)
mail_domain = "example.com"
# EDIT: domain on which you want to access gmail (must exist in control panel)
webmail_domain = "mail.example.com"
# no need to edit below this line
# mx info
mx_info = (
('ASPMX.L.GOOGLE.COM','10'),
('ALT1.ASPMX.L.GOOGLE.COM','20'),
('ALT2.ASPMX.L.GOOGLE.COM','20'),
('ASPMX2.GOOGLEMAIL.COM','30'),
('ASPMX3.GOOGLEMAIL.COM','30'),
('ASPMX4.GOOGLEMAIL.COM','30'),
('ASPMX5.GOOGLEMAIL.COM','30'),
)
# create a session
server = xmlrpclib.Server('https://api.webfaction.com/')
session_id, account = server.login(username, password)
# create mx records
for mx in mx_info:
server.create_dns_override(session_id,
mail_domain,
'',
'',
mx[0],
mx[1],
'')
# create CNAME record
server.create_dns_override(session_id,
webmail_domain,
'',
'ghs.google.com',
'',
'',
'')
# now launch a browser to make sure it all worked :D
webbrowser.open('https://panel.webfaction.com/dns/list')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment