Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save michaellopez/96c433746f63bda45415de2872b27b03 to your computer and use it in GitHub Desktop.
Save michaellopez/96c433746f63bda45415de2872b27b03 to your computer and use it in GitHub Desktop.
swiftmailer bad/missing attachment fix patch
diff --git a/src/Plugin/Mail/SwiftMailer.php b/src/Plugin/Mail/SwiftMailer.php
index e9830ac..4e0bcb9 100644
--- a/src/Plugin/Mail/SwiftMailer.php
+++ b/src/Plugin/Mail/SwiftMailer.php
@@ -479,7 +479,15 @@ class SwiftMailer implements MailInterface, ContainerFactoryPluginInterface {
$content = file_get_contents($image->uri);
}
else {
- $content = file_get_contents(\Drupal::service('file_system')->realpath($image->uri));
+ $image_path = \Drupal::service('file_system')->realpath($image->uri);
+ if (empty($image_path)) {
+ continue;
+ }
+ $content = file_get_contents($image_path);
+ }
+
+ if (empty($content)) {
+ continue;
}
$filename = $image->filename;
@michaellopez
Copy link
Author

Against 8.x-2.x (1ad24cdf841fe309f689fd3c8cdce1014114c27b)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment