Skip to content
Snippets Groups Projects

3398045 mailchimp deprecation error fix for sending attachments

+ 7
1
@@ -11,6 +11,7 @@ use Drupal\Core\Url;
use Drupal\Core\Mail\MailFormatHelper;
use Drupal\Component\Utility\Html;
use Drupal\mailchimp_transactional\MailchimpTransactionalInterface;
use Symfony\Component\Mime\MimeTypeGuesserInterface;
/**
* Allow Drupal mailsystem to use Mailchimp Transactional when sending emails.
@@ -277,7 +278,12 @@ class Mail implements MailInterface {
$filename = basename($path);
$file_buffer = file_get_contents($path);
$file_buffer = chunk_split(base64_encode($file_buffer), 76, "\n");
$mime_type = $this->mimeTypeGuesser->guess($path);
if ($this->mimeTypeGuesser instanceof MimeTypeGuesserInterface) {
$mime_type = $this->mimeTypeGuesser->guessMimeType($path);
}
else {
$mime_type = $this->mimeTypeGuesser->guess($path);
}
if (!$this->isValidContentType($mime_type)) {
throw new \Exception($mime_type . ' is not a valid content type.');
}
Loading