mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2024-11-10 13:12:50 +01:00
fixes for bccs
This commit is contained in:
parent
7594397d2a
commit
6ca955164e
@ -31,7 +31,7 @@ class GmailTransport extends AbstractTransport
|
|||||||
|
|
||||||
protected function doSend(SentMessage $message): void
|
protected function doSend(SentMessage $message): void
|
||||||
{
|
{
|
||||||
nlog("in Do Send");
|
nlog("In Do Send");
|
||||||
$message = MessageConverter::toEmail($message->getOriginalMessage());
|
$message = MessageConverter::toEmail($message->getOriginalMessage());
|
||||||
|
|
||||||
$token = $message->getHeaders()->get('gmailtoken')->getValue();
|
$token = $message->getHeaders()->get('gmailtoken')->getValue();
|
||||||
@ -45,7 +45,25 @@ class GmailTransport extends AbstractTransport
|
|||||||
$service = new Gmail($client);
|
$service = new Gmail($client);
|
||||||
|
|
||||||
$body = new Message();
|
$body = new Message();
|
||||||
$body->setRaw($this->base64_encode($message->toString()));
|
|
||||||
|
$bccs = $message->getHeaders()->get('Bcc');
|
||||||
|
|
||||||
|
$bcc_list = '';
|
||||||
|
|
||||||
|
if($bccs)
|
||||||
|
{
|
||||||
|
$bcc_list = 'Bcc: ';
|
||||||
|
|
||||||
|
foreach($bccs->getAddresses() as $address){
|
||||||
|
|
||||||
|
$bcc_list .= $address->getAddress() .',';
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
$bcc_list = rtrim($bcc_list, ",") . "\r\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
$body->setRaw($this->base64_encode($bcc_list.$message->toString()));
|
||||||
|
|
||||||
$service->users_messages->send('me', $body, []);
|
$service->users_messages->send('me', $body, []);
|
||||||
|
|
||||||
|
@ -16,7 +16,6 @@ use Microsoft\Graph\Graph;
|
|||||||
use Microsoft\Graph\Model\UploadSession;
|
use Microsoft\Graph\Model\UploadSession;
|
||||||
use Symfony\Component\Mailer\SentMessage;
|
use Symfony\Component\Mailer\SentMessage;
|
||||||
use Symfony\Component\Mailer\Transport\AbstractTransport;
|
use Symfony\Component\Mailer\Transport\AbstractTransport;
|
||||||
use Symfony\Component\Mime\Email;
|
|
||||||
use Symfony\Component\Mime\MessageConverter;
|
use Symfony\Component\Mime\MessageConverter;
|
||||||
|
|
||||||
class Office365MailTransport extends AbstractTransport
|
class Office365MailTransport extends AbstractTransport
|
||||||
@ -38,21 +37,36 @@ class Office365MailTransport extends AbstractTransport
|
|||||||
|
|
||||||
$graph->setAccessToken($token);
|
$graph->setAccessToken($token);
|
||||||
|
|
||||||
try {
|
$bccs = $symfony_message->getHeaders()->get('Bcc');
|
||||||
$graphMessage = $graph->createRequest('POST', '/users/'.$symfony_message->getFrom()[0]->getAddress().'/sendmail')
|
|
||||||
->attachBody(base64_encode($message->toString()))
|
$bcc_list = '';
|
||||||
->addHeaders(['Content-Type' => 'text/plain'])
|
|
||||||
->setReturnType(\Microsoft\Graph\Model\Message::class)
|
if($bccs)
|
||||||
->execute();
|
{
|
||||||
} catch (\Exception $e) {
|
|
||||||
sleep(5);
|
foreach($bccs->getAddresses() as $address){
|
||||||
$graphMessage = $graph->createRequest('POST', '/users/'.$symfony_message->getFrom()[0]->getAddress().'/sendmail')
|
|
||||||
->attachBody(base64_encode($message->toString()))
|
$bcc_list .= 'Bcc: "'.$address->getAddress().'" <'.$address->getAddress().'>\r\n';
|
||||||
->addHeaders(['Content-Type' => 'text/plain'])
|
|
||||||
->setReturnType(\Microsoft\Graph\Model\Message::class)
|
|
||||||
->execute();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
$graphMessage = $graph->createRequest('POST', '/users/'.$symfony_message->getFrom()[0]->getAddress().'/sendmail')
|
||||||
|
->attachBody(base64_encode($bcc_list.$message->toString()))
|
||||||
|
->addHeaders(['Content-Type' => 'text/plain'])
|
||||||
|
->setReturnType(\Microsoft\Graph\Model\Message::class)
|
||||||
|
->execute();
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
sleep(5);
|
||||||
|
$graphMessage = $graph->createRequest('POST', '/users/'.$symfony_message->getFrom()[0]->getAddress().'/sendmail')
|
||||||
|
->attachBody(base64_encode($bcc_list.$message->toString()))
|
||||||
|
->addHeaders(['Content-Type' => 'text/plain'])
|
||||||
|
->setReturnType(\Microsoft\Graph\Model\Message::class)
|
||||||
|
->execute();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function __toString(): string
|
public function __toString(): string
|
||||||
|
Loading…
Reference in New Issue
Block a user