Email::delmx function doesn't delete MX entry

rlesterphx

Member
Jul 22, 2010
21
0
51
I have a script that uses the cPanel XML API2 to set up a domain with the MX entries required to forward mail to Google Apps (7 different MX entries with varying priorities).

Since by default every domain in our system has an MX entry that points to itself with a priority of 0, I set up the first part of my Google Apps script to check for this original MX entry and delete it before adding the new ones.
Using the Email::listmx function I can find the entry fine, and then the script uses the Email::delmx function (with all three parameters) to attempt to delete that original entry. The delmx function comes back with a result of 1 (success), and then when I log in to cPanel and check the MX entries for the domain it says there aren't any.
However when I run the listmx function again for that domain it still shows the original MX entry. It also shows up in WHM.

Any ideas? Thanks!
 

rlesterphx

Member
Jul 22, 2010
21
0
51
Update:
I tried deleting the MX from WHM and that doesn't get rid of it either. I also tried restarting the BIND service but it still shows up.
I don't know why I didn't think of this before but I'm going to try adding the new MX entries first and THEN removing the original
 

MattDees

Well-Known Member
Apr 29, 2005
416
1
243
Houston, TX
cPanel Access Level
Root Administrator
I'm glad that you were able to resolve your own issue, but I'm curious as to what the problem was so that someone who encounters the same program in the future may address it.
 

rlesterphx

Member
Jul 22, 2010
21
0
51
For some reason it seems if a domain only has one MX entry you can't delete it. You'll get a success message but it's a false positive.
The solution was to add the new MX entries first and then delete the original first entry. Hope that helps someone in the future.