donglao4370
donglao4370
2016-02-19 02:10

Mailchimp首先验证用户电子邮件

  • curl
  • php

I use Laravel 5 to develop an app and I use Mailchimp for adding subscription. I use Mailchimp v.3 . I can make a list using this code:

               $mailchimp = new Mailchimp(xxxxxxxxxxxx-xx);
               $contact = [
                    'company' => $request['campaign'],
                    'address1' => $request['address'],
                    'city' => $request['city'],
                    'state' => $candidate->userCandidate->state,
                    'zip' => $request['zip'],
                    'country' => $request['country'],
                    'phone' => $request['phone'],
                ];

                $campaign_details = [
                    'from_name' => $request['from_name'],
                    'from_email' => $request['from_email'],
                    'subject' => $request['remind_text'],
                    'language' => 'English'
                ];

                $data = [
                    'name' => Auth::user()->name . ' Campaign',
                    'contact' => $contact,
                    'permission_reminder' => $request['remind_text'],
                    'campaign_defaults' => $campaign_details,
                    'notify_on_subscribe' => $request['from_email'],
                    'notify_on_unsubscribe' => $request['from_email'],
                    'email_type_option' => false,
                    'visibility' => $request['visibility'],

                ];

                $list = $mailchimp->post('lists', $data);

I use this library drewm/mailchimp. My code on subscribing is this:

$mailchimp = new Mailchimp($api_key);
  $subscriber = [
    'email_type' => 'html',
    'email_address' => $email,
    'language' => 'English',
    'status' => 'subscribed',
    'merge_fields' => ['zip' => $zip]
  ];

  $result = $mailchimp->post('lists/' . $list_id . '/members', $subscriber);

And I can successfully subscribe it. This is my question how to verify an email first before will be recorded on mailchimp list to avoid spammer. I read on mailchimp that they have DOUBLE OPT-IN method but it is only available if you use their form.

My solution is to email first on subscriber and create a link for verifying and this solution can take time. Is there another solution on this? Does Mailchimp have method to acquire this?

  • 点赞
  • 回答
  • 收藏
  • 复制链接分享

3条回答

为你推荐