Closed Method-Development closed 6 months ago
Hello @Method-Development Are you sure that you use in a correct way BCC ? Each BCC recipient will not know about another BCC. But They will see original recipient. Here is example of code usage
try {
$builder = new MessageBuilder();
$builder->setFromAddress("xxxx@gmail.com");
$builder->addBccRecipient('x1@gmail.com');
$builder->addBccRecipient('x2@gmail.com');
$builder->addToRecipient('yyyyyy@gmail.com');
$builder->setSubject('Test BCC');
$builder->setTextBody("This is the text body of the message!");
$builder->setHtmlBody("<html><p>This is the HTML body of the message</p></html>");
$res = $mgClient->messages()->send($domain, $builder->getMessage());
print_r($res);
} catch (Exception $exception) {
echo sprintf('HTTP CODE - %s,', $exception->getCode());
echo sprintf('Error - %s', $exception->getMessage());
}
@oleksandr-mykhailenko thanks for responding! This is using their bulk sending, the non-bulk works as intended.
On my phone(latest iOS using the built in mail app) I set up 3 email accounts, then used the bulk sending to email them. The first is always correct but the others show the first recipient's address and does not show the to/from/bcc properly.
This is an example of the code using their php package:
$mgClient = Mailgun::create(config('mailgunbatchsending.key'), config('mailgunbatchsending.hostname'));
$domain = config('mailgunbatchsending.domain');
$batchMessage = $mgClient->messages()->getBatchMessage($domain);
$batchMessage->setFromAddress('no-reply@mysite.com <no-reply@mysite.com>', array("site"=>'mysite'));
$batchMessage->setSubject($this->subject);
$batchMessage->setHtmlBody($this->rendered_html);
if(isset($this->users) && $this->users->count() > 0){
foreach($this->users as $user)
{
$batchMessage->addToRecipient($user->email, array('site'=>'mysite', 'unsubscribe_from_email_link' => URL::signedRoute('disableEmailNotifications', ['token' => $user->email])));
}
}
else{
$batchMessage->addToRecipient($this->to, array('site'=>'mysite', 'unsubscribe_from_email_link' => URL::signedRoute('disableEmailNotifications', ['token' => $this->to])));
}
if(isset($this->bcc)){
$batchMessage->addBccRecipient($this->bcc, array('site'=>'mysite', 'unsubscribe_from_email_link' => URL::signedRoute('disableEmailNotifications', ['token' => $this->bcc])));
}
$batchMessage->finalize();
@oleksandr-mykhailenko thanks for responding! This is using their bulk sending, the non-bulk works as intended.
On my phone(latest iOS using the built in mail app) I set up 3 email accounts, then used the bulk sending to email them. The first is always correct but the others show the first recipient's address and does not show the to/from/bcc properly.
This is an example of the code using their php package:
$mgClient = Mailgun::create(config('mailgunbatchsending.key'), config('mailgunbatchsending.hostname')); $domain = config('mailgunbatchsending.domain'); $batchMessage = $mgClient->messages()->getBatchMessage($domain); $batchMessage->setFromAddress('no-reply@mysite.com <no-reply@mysite.com>', array("site"=>'mysite')); $batchMessage->setSubject($this->subject); $batchMessage->setHtmlBody($this->rendered_html); if(isset($this->users) && $this->users->count() > 0){ foreach($this->users as $user) { $batchMessage->addToRecipient($user->email, array('site'=>'mysite', 'unsubscribe_from_email_link' => URL::signedRoute('disableEmailNotifications', ['token' => $user->email]))); } } else{ $batchMessage->addToRecipient($this->to, array('site'=>'mysite', 'unsubscribe_from_email_link' => URL::signedRoute('disableEmailNotifications', ['token' => $this->to]))); } if(isset($this->bcc)){ $batchMessage->addBccRecipient($this->bcc, array('site'=>'mysite', 'unsubscribe_from_email_link' => URL::signedRoute('disableEmailNotifications', ['token' => $this->bcc]))); } $batchMessage->finalize();
Oh, I see now. SO let me test this. And I will back to you with answer. I can't promise to answer you today, But for tomorrow I will be ready.
Thank you for providing example, it's much better now to understand the flow of the code
Hello @Method-Development So I tested a few scenarios. Looks like it was designed to work in the next way.
If you use only addToRecipient
- each recipient will not know about another. Just separated email to each recipient.
If you user addCcRecipient
- email app will show you the addresses of the copy of this email
if you use - addBccRecipient
- it's a hidden copy and nobody will know about them. It's regular behavior.
$batchMessage = $mgClient->messages()->getBatchMessage($domain);
$batchMessage->setFromAddress('mihaskep@gmail.com');
$batchMessage->setSubject('BATCH TEST');
$batchMessage->setHtmlBody("<html><p>This is the HTML body of the message</p></html>");
$batchMessage->addToRecipient('xxx@gmail.com');
$batchMessage->addCcRecipient('yyy@gmail.com');
$batchMessage->addBccRecipient('zzz@gmail.com');
$batchMessage->finalize();
What does CC mean in email? By putting the email address(es) in the Cc field you send a copy of the email to those recipient(s) for their information only, indicating that no reply is required or expected. Those email addresses are also visible to the main recipient (whose address is in the “To” field) and they can decide whether to reply to the sender only (by choosing “Reply”) or to also include the cc’ed addresses (by clicking “Reply all”). What does BCC mean in email? The recipients you add in the Bcc field are invisible to all other recipients (under To or Cc). This option is useful if you prefer to keep the email addresses private. It also means that the bcc'ed recipients will not receive any reply emails from the other recipients, even if they select “Reply all”. In other words, the difference between cc and bcc is that both are used for sending emails to additional recipients, but only you as the sender can see all the names listed under Bcc.
@oleksandr-mykhailenko yeah I'm using the BCC it works as intended with one to email but if you use recipient variables and multiple to addresses it does not work as intended.
So if you do this:
$batchMessage->addToRecipient("email1@gmail.com", array('site'=>'mysite', 'unsubscribe_from_email_link' => URL::signedRoute('disableEmailNotifications', ['token' => $user->email])));
$batchMessage->addToRecipient("email2@gmail.com", array('site'=>'mysite', 'unsubscribe_from_email_link' => URL::signedRoute('disableEmailNotifications', ['token' => $user->email])));
$batchMessage->addToRecipient("email3@gmail.com", array('site'=>'mysite', 'unsubscribe_from_email_link' => URL::signedRoute('disableEmailNotifications', ['token' => $user->email])));
$batchMessage->addBccRecipient("hiddenaddress@gmail.com", array('site'=>'mysite', 'unsubscribe_from_email_link' => URL::signedRoute('disableEmailNotifications', ['token' => $this->bcc])));
And you'll notice 2 of the 3 will have an incorrect setup when they receive the email(wrong to)
Hello @Method-Development So I tested your way of sending and for me everything worked as expected.
Here is my code example
$batchMessage = $mgClient->messages()->getBatchMessage($domain);
$batchMessage->setFromAddress('mihaskep@gmail.com');
$batchMessage->setSubject('BATCH TEST');
$batchMessage->setHtmlBody("<html><p>This is the HTML body of the message</p></html>");
$batchMessage->addToRecipient('email1@gmail.com');
$batchMessage->addToRecipient('email2@gmail.com');
$batchMessage->addToRecipient('email3@gmail.com');
$batchMessage->addBccRecipient('email4@xxxx.com');
$batchMessage->finalize();
So me result was next:
Each email has only 1 recipient info, as expected; Here is my real example
And BCC email does not see any recipients. Maybe I did not understand you in a correct way.
Yeah, web interfaces work fine. It is just on a mobile phone that it does that. In my browser it's fine, in iOS mail application is where the error occurs. Could be iOS related but I'm not 100% sold on that yet.
Yeah, web interfaces work fine. It is just on a mobile phone that it does that. In my browser it's fine, in iOS mail application is where the error occurs. Could be iOS related but I'm not 100% sold on that yet.
So looks like iOS issue, really. Maybe headers were recognized in a wrong way. Let me also try to find same issues in google. Maybe I can find more information
So looks like this problem is not new and many people faced with that. What I can say, you can only try some solution from next links, because looks like, it's only on their end
https://discussions.apple.com/thread/255160893?answerId=259599017022&sortBy=best#259599017022 https://discussions.apple.com/thread/254327086?sortBy=best https://support.google.com/mail/thread/170898410/bcc-not-working-in-mac-mail?hl=en
Issue seen on mobile iOS.
If you do “addRecipient” it works properly but if you use “addBccRecipient” the first email goes to the correct person but subsequent emails go to whoever was BCC’d.