Question
How can I update MX records using the command line?
Answer
cPanel's UAPI allows you to add, remove and replace MX records:
Add MX record:
uapi --user=username Email add_mx domain='example.com' exchanger='mail.example.com' priority='5'
Remove MX record:
uapi --user=username Email delete_mx domain='example.com' exchanger='mail.example.com' priority='15'
Update existing MX record:
uapi --user=username Email change_mx domain='example.com' exchanger='mail.example.com' oldexchanger='mail.example.com' priority='15'