Seeing errors when sending a mail with files attached as file contents

Created on 25 August 2017, about 7 years ago
Updated 12 April 2024, 7 months ago

When sending an email with a pdf attachment you get the following errors:

Warning: realpath() expects parameter 1 to be a valid path, string given in Drupal\Core\File\FileSystem->realpath() (line 129 of core/lib/Drupal/Core/File/FileSystem.php).

Warning: is_file() expects parameter 1 to be a valid path, string given in Drupal\mimemail\Utility\MimeMailFormatHelper::mimeMailMultipartBody() (line 474 of modules/contrib/mimemail/src/Utility/MimeMailFormatHelper.php).

๐Ÿ› Bug report
Status

RTBC

Version

1.0

Component

Code

Created by

๐Ÿ‡ฟ๐Ÿ‡ฆSouth Africa janehollander

Live updates comments and jobs are added and updated live.
  • Needs tests

    The change is currently missing an automated test that fails when run with the original code, and succeeds when the bug has been fixed.

Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • ๐Ÿ‡ซ๐Ÿ‡ทFrance aiphes

    Hi,
    As in #47, I still get this error with WSOD. v 8.x-1.0-alpha4

    The website encountered an unexpected error. Please try again later.
    ValueError: realpath(): Argument #1 ($path) must not contain any null bytes in realpath() (line 139 of core/lib/Drupal/Core/File/FileSystem.php).
    realpath('') (Line: 139)
    Drupal\Core\File\FileSystem->realpath('') (Line: 395)
    Drupal\mimemail\Utility\MimeMailFormatHelper::mimeMailFile(NULL, '', 'google_analytics_audience-_-_brise-lames.pdf', 'application/pdf', 'attachment') (Line: 216)
    Drupal\mimemail\Utility\MimeMailFormatHelper::mimeMailHtmlBody('
        Mime Mail message template
            test envoi pj
    ', 'Poste recherchรฉ dans le domaine [webform_submission:webform:element:poste_recherche:raw]', , 'test envoi pj
    ', Array) (Line: 206)
    Drupal\mimemail\Plugin\Mail\MimeMail->prepareMessage(Array) (Line: 105)
    Drupal\mimemail\Plugin\Mail\MimeMail->format(Array) (Line: 43)
    Drupal\mailsystem\Adapter->format(Array) (Line: 289)

    Do I need to patch the module or something else ?
    Thanks

  • ๐Ÿ‡จ๐Ÿ‡ณChina qqboy

    locally, if I use

    $params['attachments'][] = [
    'filepath' => $file->getFileUri(),
    ];

    avoided this patch, since this patch is stilled not imported to Module itself in alph-4.

  • ๐Ÿ‡ซ๐Ÿ‡ทFrance mably

    Patch #39 doesn't work with latest alpha5 :(

  • ๐Ÿ‡ซ๐Ÿ‡ทFrance mably

    Tried to port #39 patch to alpha5 source code. Seems to work, not heavily tested though.

  • ๐Ÿ‡บ๐Ÿ‡ฆUkraine _tarik_ Lutsk

    #55 +1 worked for me, PHP 8.1.16 - D9.5.8

  • ๐Ÿ‡ฎ๐Ÿ‡นItaly kris77

    #55 +1 worked for me to with latest alpha5.

    Thanks @mably.

  • Open in Jenkins โ†’ Open on Drupal.org โ†’
    Core: 10.0.7 + Environment: PHP 8.1 & MySQL 5.7
    last update over 1 year ago
    27 pass
  • ๐Ÿ‡บ๐Ÿ‡ธUnited States RyanCMcConnell

    #55 worked for me as well. Thank you @mably !

  • Status changed to RTBC 11 months ago
  • ๐Ÿ‡ฎ๐Ÿ‡นItaly kris77

    #55 works for me too.
    Thanks @mably

  • ๐Ÿ‡ฆ๐Ÿ‡บAustralia Bagz

    #55 works with alpha6 on Drupal 10.2.3 with PHP 8.2.16

  • ๐Ÿ‡ญ๐Ÿ‡บHungary betarobot

    #55 worked well with PHP 8.2.17 and Drupal 10.2.5.

Production build 0.71.5 2024