Email shows file content instead of file attachment

Created on 20 September 2024, 2 months ago

Problem/Motivation

Email shows file content instead of file attachment

I'm sending an email with attachment using below code

$params['attachment'] = [
        'filecontent' => file_get_contents($file->getFileUri()),
        'filename' => $file->getFileName(),
        'filemime' => $file->getMimeType(),
      ];

But I'm getting file content in the email instead of attached file. Using Default PHP mailer to send emails. And checking on Microsoft Outlook.

🐛 Bug report
Status

Active

Version

1.5

Component

Code

Created by

🇮🇳India dhruveshdtripathi

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @dhruveshdtripathi
  • 🇩🇪Germany gogowitsch

    Interesting! Which operating system / distro is your Drupal instance running on? If it runs in a container: which distro is that?

    Also helpful would be a zip file with all the YAML files that the command drush cex produces. Feel free to redact all private information. Leave out files you believe are not relevant to the email problem.

  • 🇩🇪Germany gogowitsch

    Feel free to answer just with the information you have. If the drush cex part seems too hard, just leave it out.

  • 🇩🇪Germany gogowitsch

    The code posted by dhruveshdtripathi looks correct. Without a way to debug the issue on my machine, I cannot help.

    I will therefore now close this issue.

Production build 0.71.5 2024