email not being added to mailing list

98 views Asked by At

Am trying to using Services Mailman php api to add emails to a mailing list created at the backend with the site cpanel but no email is being added.

Here is my code

    require './Services/Mailman.php';
    $mm = new Services_Mailman( 'http://example.com/mailman/admin/', 'newsletter', NEWSLETTER_PASS );
    try {
        // $mailinglists = $mm->lists();
        // foreach ( $mailinglists as $list ) {
        //     echo $list['name'] . "\n";
        // }
        var_dump( $mm->subscribe('[email protected]') );
    } catch ( Services_Mailman_Exception $e ) {
        die( 'Error: ' . $e->getMessage() );
    }

Here is a screenshot of my var_dump

enter image description here

I don't what the problem could be, is it the admin url that i am using or is it something else because everything from the mailing list password and list name provided are correct. Please help. Thank you.

1

There are 1 answers

0
kellymandem On

I figured out a solution by looking at their comments for the subscribe method below in which i noticed i had input the mailing list the wrong way by just naming it instead adding the other details i.e newsletter_example.com and no it's not [email protected] for some reason.

You can look at the comments for the subscribe method to figure it out.

/**
 * Subscribe
 *
 * (ie: http://example.co.uk/mailman/admin/test_example.co.uk/members/add
 * ?subscribe_or_invite=0&send_welcome_msg_to_this_batch=1
 * &send_notifications_to_list_owner=0&subscribees=test%40example.co.uk
 * &invitation=&setmemberopts_btn=Submit+Your+Changes)
 *
 * @param string  $email  Valid email address to subscribe
 * @param boolean $invite Send an invite or not (default)
 *
 * @return Services_Mailman
 *
 * @throws Services_Mailman_Exception
 */
public function subscribe($email, $invite = false) {}