The Community Forums

Interact with an entire community of cPanel & WHM users!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Email::delmx function doesn't delete MX entry

Discussion in 'cPanel Developers' started by rlesterphx, May 6, 2011.

  1. rlesterphx

    rlesterphx Member

    Joined:
    Jul 22, 2010
    Messages:
    21
    Likes Received:
    0
    Trophy Points:
    1
    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!
     
  2. rlesterphx

    rlesterphx Member

    Joined:
    Jul 22, 2010
    Messages:
    21
    Likes Received:
    0
    Trophy Points:
    1
    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
     
  3. rlesterphx

    rlesterphx Member

    Joined:
    Jul 22, 2010
    Messages:
    21
    Likes Received:
    0
    Trophy Points:
    1
    That fixed it! Woot for self-solving threads.
     
  4. MattDees

    MattDees cPanel Product Owner
    Staff Member

    Joined:
    Apr 29, 2005
    Messages:
    417
    Likes Received:
    1
    Trophy Points:
    18
    Location:
    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.
     
  5. rlesterphx

    rlesterphx Member

    Joined:
    Jul 22, 2010
    Messages:
    21
    Likes Received:
    0
    Trophy Points:
    1
    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.
     
Loading...

Share This Page