Skip to content

Instantly share code, notes, and snippets.

@haraldmartin
Created December 5, 2012 20:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save haraldmartin/4219304 to your computer and use it in GitHub Desktop.
Save haraldmartin/4219304 to your computer and use it in GitHub Desktop.
Add Google Apps MX records to a Loopia domain
#!/usr/bin/env ruby
require 'xmlrpc/client'
USERNAME = 'username' # get username
PASSWORD = 'password' # and password @ https://www.loopia.se/api
RPC_SERVER = "https://api.loopia.se/RPCSERV"
DOMAIN = 'harald.net' # change to the domain you want to use
# http://www.google.com/support/a/bin/answer.py?answer=174125
records = [
{ "priority" => 1, "rdata" => "ASPMX.L.GOOGLE.COM." },
{ "priority" => 5, "rdata" => "ALT1.ASPMX.L.GOOGLE.COM." },
{ "priority" => 5, "rdata" => "ALT2.ASPMX.L.GOOGLE.COM." },
{ "priority" => 10, "rdata" => "ASPMX2.GOOGLEMAIL.COM." },
{ "priority" => 10, "rdata" => "ASPMX3.GOOGLEMAIL.COM." },
{ "priority" => 10, "rdata" => "ASPMX4.GOOGLEMAIL.COM." },
{ "priority" => 10, "rdata" => "ASPMX5.GOOGLEMAIL.COM." },
].map { |r| r.update({ "ttl" => 3600, "type" => "MX" }) }
client = XMLRPC::Client.new2(RPC_SERVER)
records.each do |record|
status = client.call('addZoneRecord', USERNAME, PASSWORD, "", DOMAIN, "@", record)
puts "Adding #{record['rdata']} to domain #{DOMAIN}..."
puts status
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment