Error while sending test mail

Created on 28 June 2024, 6 months ago
Updated 5 September 2024, 3 months ago

Problem/Motivation

Getting an error while sending test email

Steps to reproduce

1. Goto /admin/config/services/mailchimp_transactional/test
2. submit the form
3. You would be getting this below error:

The website encountered an unexpected error. Try again later.

TypeError: is_file(): Argument #1 ($filename) must be of type string, bool given in is_file() (line 140 of modules/contrib/mailchimp_transactional/src/Plugin/Mail/Mail.php).
Drupal\mailchimp_transactional\Plugin\Mail\Mail->mail() (Line: 138)
Drupal\mailchimp_transactional\Form\AdminTestForm->submitForm()
call_user_func_array() (Line: 129)
Drupal\Core\Form\FormSubmitter->executeSubmitHandlers() (Line: 67)
Drupal\Core\Form\FormSubmitter->doSubmitForm() (Line: 597)
Drupal\Core\Form\FormBuilder->processForm() (Line: 325)
Drupal\Core\Form\FormBuilder->buildForm() (Line: 73)
Drupal\Core\Controller\FormController->getContentResult()
call_user_func_array() (Line: 123)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 627)
Drupal\Core\Render\Renderer->executeInRenderContext() (Line: 121)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext() (Line: 97)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 181)
Symfony\Component\HttpKernel\HttpKernel->handleRaw() (Line: 76)
Symfony\Component\HttpKernel\HttpKernel->handle() (Line: 43)
Drupal\force_password_change\Service\ForcePasswordChangeRedirectMiddleware->handle() (Line: 58)
Drupal\Core\StackMiddleware\Session->handle() (Line: 48)
Drupal\Core\StackMiddleware\KernelPreHandle->handle() (Line: 28)
Drupal\Core\StackMiddleware\ContentLength->handle() (Line: 53)
Asm89\Stack\Cors->handle() (Line: 50)
Drupal\ban\BanMiddleware->handle() (Line: 48)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle() (Line: 51)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle() (Line: 36)
Drupal\Core\StackMiddleware\AjaxPageState->handle() (Line: 51)
Drupal\Core\StackMiddleware\StackedHttpKernel->handle() (Line: 704)
Drupal\Core\DrupalKernel->handle() (Line: 19)

Proposed resolution

1. Check $message['attachments']: Ensure $message['attachments'] is an array before iterating through it.
2. Validate $attachment: Verify $attachment is a string (is_string($attachment)) before checking if it's a valid file (is_file($attachment)).
3. Add Valid Attachments: If is_file() returns true for $attachment, add it to $attachments using getAttachmentStruct().

Remaining tasks

User interface changes

API changes

Data model changes

🐛 Bug report
Status

Needs review

Version

1.1

Component

Code

Created by

🇮🇳India deepakaryan1988

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

Comments & Activities

Production build 0.71.5 2024