Add Google Apps MX records to a Loopia domain
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |