Pistol pistol title issue

Using this feature to send bulk mail via the mail console

`// send batch mail public function BatchMail ($ subject = null, $ body = null, $ record = null) {# Create client instance. $ mg = new Mailgun (MAILGUN_KEY); $ domain = MAILGUN_DOMAIN;

    # Next, instantiate a Message Builder object from the SDK, pass in your sending domain
    if(!empty($record))
    {
        $batchMsg = $mg->BatchMessage($domain);

        # Define the from address.
        $batchMsg->setFromAddress(FROM_EMAIL, array("first"=>FIRST_NAME, "last" => LAST_NAME));

        # Define the subject. 
        $batchMsg->setSubject($subject);

        # Define the body of the message.
        $batchMsg->setHtmlBody($body);

        # Next, let add a few recipients to the batch job.
        foreach ($record as $key => $rec) {

            $batchMsg->addToRecipient($rec['email'], array("first" => $rec['fname'], "last" => $rec['lname']));
        }
        $batchMsg->addCcRecipient("mayname@mycompany.in", array("first" => "Sally", "last" => "Doe"));

        $re     = $batchMsg->finalize();
        $result = $batchMsg->getMessage();

        $log    = $mg->get("$domain/log");
        $respbody = $log->http_response_body;
        $result = $mg->get("$domain/stats",array('event' => array('sent', 'opened')));
        $resp   = $log->http_response_code;
        //$event  = $mg->get("$domain/events");
        $response = array("log"=>$log,"result"=>$result,"body"=>$respbody,"code"=>$resp);
        return  $response;
    }   
}`

      

Here emails are being sent correctly, but I have a problem with my email.

$batchMsg->addCcRecipient("mayname@mycompany.in", array("first" => "Sally", "last" => "Doe"));

This function is used to add CC letters. Mail is working correctly, but mail resumes with headers like To: mayname@mycompany.in , Cc: mayname@mycompany.in. But the recipients' emails are not listed in the headers.

Usually gamil shows recipients in headers like this to: test@gmail.com cc: myname@mycompany.in

Does anyone know why the mail console is showing such a problem?

+3


source to share


1 answer


Replace:

   foreach ($record as $key => $rec) {
       $batchMsg->addToRecipient($rec['email'], array("first" => $rec['fname'], "last" => $rec['lname']));
   }

      

FROM

   foreach ($record as $key => $rec) {
       $batchMsg->addBccRecipient($rec['email'], array("first" => $rec['fname'], "last" => $rec['lname']));
   }

      



Or, if you want your recipients to know who else has been emailed, then don't use the batch message builder. For correct formatting, see the To parameter in the email API documentation .

The batch builder is designed to send many individual emails, rather than composing a single letter to many different recipients. MailGun may not have expected you to create an email to multiple recipients this way, and thus there is no validation of coverage for this error. You can try submitting a bug report on their github page .

More details on the spec you are trying to implement may lead to a better answer.

0


source







All Articles