1

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('kelly@example.com') );
    } 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.

4

1 回答 1

1

我通过查看他们对下面订阅方法的评论找到了一个解决方案,其中我注意到我通过命名而不是添加其他详细信息以错误的方式输入了邮件列表newsletter_example.com,不,不是newsletter@example.com出于某种原因。

您可以查看 subscribe 方法的注释以找出答案。

/**
 * 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) {}
于 2017-09-09T11:41:00.533 回答