开发者

Send an email via MailChimp

I think problem is around $api->listSubscribers()

include('../libs/mailchimp/MCAPI.class.php');

$options = array('list_id' => '$list_id', 'subject' => 'Prova', 'from_name' => 'name', 'from_email' => 'info@example.com');
$content = array('html' => '<p>Testo di prova</p>');

$api = new MCAPI($apikey);
$campaignI开发者_开发技巧d = $api->campaignCreate('trans', $options, $content);

$api->listSubscribe($options['list_id']);

$api->campaignSendNow($campaignId);

if ($api->errorCode){
    echo "Unable to Create New Campaign!";
    echo "\n\tCode=".$api->errorCode;
    echo "\n\tMsg=".$api->errorMessage."\n";
} else {
    echo "New Campaign ID:".$campaignId ."\n";
}

Why does'nt it send an email?


You have a several issues here:

The first one is that you are not doing error checking after each API call. If you take the error checking code from the bottom and stick it after the listSubscribe() call, you'll immediately get an error because you aren't passing any sort of subscriber data (at the very least you need the email address). The docs for listSubscribe are here

Once you do that - unless you've thoroughly read and considered the options in the listSubscribe docs - your second issue is going to be that you are running listSubscribe with the double_optin parameter set to true (the default), which means they won't be subscribed until clicking a link in the confirmation email.

Next, that code is just going to get you in trouble, and probably quickly. If you are going to use psuedo-transcational campaigns it is imperrative that you only create ONE psuedo-trans campaign per type of email and then send that campaign over and over. That's how they are intended to work. Not doing that is going to cause you to fill up your account with a whole bunch of trash campaigns at which point there's no point in using a psuedo-trans campaign since that's the same as creating/sending a regular campaign to a single user over and over.


Do you get any errors?

It seems you are not including the api key, it should look like:

$api = new MCAPI($apikey);

Instead of:

$api = new MCAPI('apikey');

You get the API Key from your api dashboard: http://admin.mailchimp.com/account/api

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜