1

メールをバッチ処理する必要がありますが、最後のメールでのみメールを取得します。

私のコードは

    $MailData            = array();
    $MailData['from']    = "John Doe <john@domain.com>";

    $MailData['to']      = 'sample1@gmail.com';
    $MailData['to']      = 'sample2@gmail.com';

    $MailData['recipient-variables']      = '{"sample1@gmail.com": {"first":"Bob", "id":1}, "sample2@gmail.com": {"first":"Alice", "id": 2}}';
    $MailData['subject'] = 'This is test thing';
    $MailData['text']    = 'How are you man';


    $ch = curl_init();
    curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
    curl_setopt($ch, CURLOPT_USERPWD, 'api:'.$api_key);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'POST');
    curl_setopt($ch, CURLOPT_URL, 'https://api.mailgun.net/v3/'.$domain.'/messages');
    curl_setopt($ch, CURLOPT_POSTFIELDS, $MailData);
    $result = curl_exec($ch);
    curl_close($ch);
    return $result;

しかし、メールは sample2@mail.com しか来ない

これはドキュメントから入手したソースコードです

curl -s --user 'api:YOUR_API_KEY' \
    https://api.mailgun.net/v3/YOUR_DOMAIN_NAME/messages \
    -F from='Excited User <YOU@YOUR_DOMAIN_NAME>' \
    -F to=alice@example.com \
    -F to=bob@example.com \
    -F recipient-variables='{"bob@example.com": {"first":"Bob", "id":1}, "alice@example.com": {"first":"Alice", "id": 2}}' \
    -F subject='Hey, %recipient.first%' \
    -F text='If you wish to unsubscribe, click http://mailgun/unsubscribe/%recipient.id%'
4

2 に答える 2

2

これを試して

$MailData['to'] = 'sample1@gmail.com, sample2@gmail.com';

于 2018-08-09T11:46:28.890 に答える