8000 fix sendgrid namespace for v7.0 by xav-hydra · Pull Request #15 · expertcoder/SwiftmailerSendGridBundle · GitHub
[go: up one dir, main page]

Skip to content

fix sendgrid namespace for v7.0 #15

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 27, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions src/Services/SendGridTransport.php
Original file line number Diff line number Diff line change
Expand Up @@ -97,27 +97,27 @@ public function send(Swift_Mime_SimpleMessage $message, &$failedRecipients = nul
$fromName = reset($fromArray);
$fromEmail = key($fromArray);

$mail = new SendGrid\Mail(); //Intentionally not using constructor arguments as they are tedious to work with
$mail = new SendGrid\Mail\Mail(); //Intentionally not using constructor arguments as they are tedious to work with

// categories can be useful if you use them like tags to, for example, distinguish different applications.
foreach ($this->sendGridCategories as $category) {
$mail->addCategory($category);
}

$mail->setFrom(new SendGrid\Email($fromName 8000 , $fromEmail));
$mail->setFrom(new SendGrid\Mail\From($fromEmail, $fromName));
$mail->setSubject($message->getSubject());

// extract content type from body to prevent multi-part content-type error
$finfo = new finfo(FILEINFO_MIME_TYPE);
$contentType = $finfo->buffer($message->getBody());
$mail->addContent(new SendGrid\Content($contentType, $message->getBody()));
$mail->addContent(new SendGrid\Mail\Content($contentType, $message->getBody()));

$personalization = new SendGrid\Personalization();
$personalization = new SendGrid\Mail\Personalization();

// process TO
if ($toArr = $message->getTo()) {
foreach ($toArr as $email => $name) {
$personalization->addTo(new SendGrid\Email($name, $email));
$personalization->addTo(new SendGrid\Mail\To($email, $name));
++$sent;
$prepareFailedRecipients[] = $email;
}
Expand All @@ -126,7 +126,7 @@ public function send(Swift_Mime_SimpleMessage $message, &$failedRecipients = nul
// process CC
if ($ccArr = $message->getCc()) {
foreach ($ccArr as $email => $name) {
$personalization->addCc(new SendGrid\Email($name, $email));
$personalization->addCc(new SendGrid\Mail\Cc($email, $name));
++$sent;
$prepareFailedRecipients[] = $email;
}
Expand All @@ -135,7 +135,7 @@ public function send(Swift_Mime_SimpleMessage $message, &$failedRecipients = nul
// process BCC
if ($bccArr = $message->getBcc()) {
foreach ($bccArr as $email => $name) {
$personalization->addBcc(new SendGrid\Email($name, $email));
$personalization->addBcc(new SendGrid\Mail\Bcc($email, $name));
++$sent;
$prepareFailedRecipients[] = $email;
}
Expand All @@ -145,7 +145,7 @@ public function send(Swift_Mime_SimpleMessage $message, &$failedRecipients = nul
if ($attachments = $message->getChildren()) {
foreach ($attachments as $attachment) {
if ($attachment instanceof Swift_Mime_Attachment) {
$sAttachment = new SendGrid\Attachment();
$sAttachment = new SendGrid\Mail\Attachment();
$sAttachment->setContent(base64_encode($attachment->getBody()));
$sAttachment->setType($attachment->getContentType());
$sAttachment->setFilename($attachment->getFilename());
Expand All @@ -154,7 +154,7 @@ public function send(Swift_Mime_SimpleMessage $message, &$failedRecipients = nul
$mail->addAttachment($sAttachment);
} elseif (in_array($attachment->getContentType(), ['text/plain', 'text/html'])) {
// add part if any is defined, to avoid error please set body as text and part as html
$mail->addContent(new SendGrid\Content($attachment->getContentType(), $attachment->getBody()));
$mail->addContent(new SendGrid\Mail\Content($attachment->getContentType(), $attachment->getBody()));
}
}
}
Expand Down
0