通过 MailChimp 发送电子邮件

发布于 2024-10-21 12:06:07 字数 869 浏览 1 评论 0原文

我认为问题出在 $api->listSubscribers()

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

$options = array('list_id' => '$list_id', 'subject' => 'Prova', 'from_name' => 'name', 'from_email' => '[email protected]');
$content = array('html' => '<p>Testo di prova</p>');

$api = new MCAPI($apikey);
$campaignId = $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";
}

为什么它不发送电子邮件?

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' => '[email protected]');
$content = array('html' => '<p>Testo di prova</p>');

$api = new MCAPI($apikey);
$campaignId = $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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

新雨望断虹 2024-10-28 12:06:07

这里有几个问题:

第一个问题是您没有在每次 API 调用后进行错误检查。如果您从底部获取错误检查代码并将其粘贴在 listSubscribe() 调用之后,您将立即收到错误,因为您没有传递任何类型的订阅者数据(至少您需要电子邮件地址)。 listSubscribe 的文档位于此处

一旦你这样做了 - 除非你已经彻底阅读并考虑了 listSubscribe 文档中的选项 - 您的第二个问题是您正在运行 listSubscribe 并将 double_optin 参数设置为 true (默认值),这意味着在单击确认电子邮件中的链接之前它们不会被订阅。

接下来,该代码只会给您带来麻烦,而且可能很快就会给您带来麻烦。如果您打算使用伪交易营销活动,则必须为每种类型的电子邮件只创建一个伪交易营销活动,然后一遍又一遍地发送该营销活动。这就是他们的工作方式。不这样做会导致您的帐户充满一大堆垃圾广告系列,此时使用伪反式广告系列是没有意义的,因为这与创建/发送常规广告系列给单个用户相同超过。

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.

稀香 2024-10-28 12:06:07

你有任何错误吗?

您似乎没有包含 api 密钥,它应该如下所示:

$api = new MCAPI($apikey);

而不是:

$api = new MCAPI('apikey');

您从 api 仪表板获取 API 密钥: http://admin.mailchimp.com/account/api

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文