Please whitelist cPanel in your adblocker so that you’re able to see our version release promotions, thanks!

The Community Forums

Interact with an entire community of cPanel & WHM users!

Add autoresponder error - XML API PHP Class

Discussion in 'cPanel Developers' started by slusatel, Nov 10, 2012.

  1. slusatel

    slusatel Registered

    Joined:
    Nov 10, 2012
    Messages:
    2
    Likes Received:
    0
    Trophy Points:
    1
    cPanel Access Level:
    Reseller Owner
    Hello.

    I'm using the following code to add autoresponder.
    PHP:

        
    include("xmlapi.php");

        
    //=======================================
        
    $server "127.0.0.1";
        
    $auser "cPanel username";
        
    $pass "The Password";
        
    $port '2083';
        
    $domain 'domain.tld';

        
    //=======================================

        
    $xmlapi = new xmlapi($server);
        
    $xmlapi->set_port(2083);
        
    $xmlapi->password_auth($auser,$pass);
        
    $xmlapi->set_debug(1);


                
    // Add new Email autoresponder
                
    $add_a_email $_POST['add_a_email'];
                
    $add_a_from_name $_POST['add_a_from_name'];
                
    $add_a_subject $_POST['add_a_subject'];
                
    $add_a_content $_POST['add_a_content'];
                
    $add_a_start $_POST['add_a_start'];
                
    $add_a_stop $_POST['add_a_stop'];
                
    $args = array(
                    
    'email' => $add_a_email,
                    
    'from' => $add_a_from_name,
                    
    'subject' => $add_a_subject,
                    
    'body'    => $add_a_content,
                    
    'domain' => $domain,
                    
    'html'    => '0',
                    
    'interval'    =>    '3600',
                    
    'start'    =>    $add_a_start,
                    
    'stop'    => $add_a_stop
                
    );
                
    $response $xmlapi->api1_query($auser"Email""addautoresponder"$args);
    But each time I submit the info, I get an error message
    "You must specify an email address. Ignore any messages of success. This can only result in failure!"

    Any idea what I'm doing wrong ?

    This is the error_log output

    Code:
    DATA: cpanel_xmlapi_user=the_user_name&cpanel_xmlapi_module=Email&cpanel_xmlapi_func=addautoresponder&cpanel_xmlapi_apiversion=1
    
    RESPONSE:
     <?xml version="1.0" ?>
    <cpanelresult><module>Email</module><func>addautoresponder</func><type>event</type><source>internal</source><apiversion>1</apiversion><data><result>&lt;br /&gt;
    &lt;font color=&quot;#FF0000&quot;&gt;
    You must specify an email address.
    Ignore any messages of success. This can only result in failure!
    &lt;/font&gt;
    </result></data>  <event>
        <result>1</result>
      </event>
      <postevent>
        <result>1</result>
      </postevent>
      <preevent>
        <result>1</result>
      </preevent>
    </cpanelresult>
    [10-Nov-2012 06:58:37] SimpleXML var_dump:
    SimpleXMLElement Object
    (
        [module] => Email
        [func] => addautoresponder
        [type] => event
        [source] => internal
        [apiversion] => 1
        [data] => SimpleXMLElement Object
            (
                [result] => <br />
    <font color="#FF0000">
    You must specify an email address.
    Ignore any messages of success. This can only result in failure!
    </font>
    
     
  2. colink

    colink Member

    Joined:
    Sep 24, 2012
    Messages:
    10
    Likes Received:
    1
    Trophy Points:
    3
    Location:
    Hillsboro, OR
    cPanel Access Level:
    DataCenter Provider
    I think your problem is that addautoresponder is an API1 function, which uses an array for positional arguments, and you're passing in a hash of arguments.

    Try changing your code to this:

    $args = array($add_a_email, $add_a_from_name, $add_a_subject, $add_a_content, $domain, '0', '3600', $add_a_start, $add_a_stop );
     
  3. slusatel

    slusatel Registered

    Joined:
    Nov 10, 2012
    Messages:
    2
    Likes Received:
    0
    Trophy Points:
    1
    cPanel Access Level:
    Reseller Owner
    Hi Colink
    That was the solution, I forgot to update the thread.

    Thanks!
     
Loading...

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice