-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Email headers from form not respected #14608
base: 5.2
Are you sure you want to change the base?
Email headers from form not respected #14608
Conversation
Since form does not require the input for the headers, we use system default if headers are not specified on the form.
@escopecz or any other Mautic member, I would appreciate some guidance on fixing this failing checks, I do not think I am approaching this the right way. It broke a lot of tests for simple change. Traceback is not accurate when I go look into source code when trying to debug and fix the checks. Thanks in advance. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that what you are trying to do here is already handled in https://github.com/mautic/mautic/blob/6.x/app/bundles/EmailBundle/Helper/FromEmailHelper.php, isn't it? If not, it should be implemented there.
@@ -11,7 +11,7 @@ final class AddressDTO | |||
{ | |||
private ?string $name = null; | |||
|
|||
public function __construct(private string $email, ?string $name = null) | |||
public function __construct(private ?string $email, ?string $name = null) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why the email address is allowed to be null? I don't understand this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was just a desperate attempt to make the test pass. I guess I will have to run tests on the machine and not commit until they actually pass, otherwise we will have way to many commits here. The message from the test I think suggested that email was null, which was also puzzling since I imagined there is no way it could be null the way I structured the solution.
$subject = $email->getSubject(); | ||
|
||
// Set message settings from the email | ||
$this->setSubject($subject); | ||
$this->setSubject($subject) ?? ''; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess you meant
$this->setSubject($subject) ?? ''; | |
$this->setSubject($subject ?? ''); |
But even that wouldn't be OK to do just to make the unit tests pass. I'd make sure that the subject is set in the Email entity in the test and if the Email entity is mocked then the getSubject
method must be configured on the mock to return a string. I'm not sure why the tests fail this way though. I don't see any change in subject here.
thanks for the pointers. I can see this file: FromEmailHelper.php, is trying to do some things, that are handled by the PR, but I am not sure its all of them. The second thing is that when you go and you test this in GUI it does not work, thats why I introduced the changes. But you make a good point, that putting the logic for defaults in the helper would make more sense. Will try to move this logic to helper class and make the test pass. |
Yep, the FROM setting is a mine field to get it to work for all use cases. I recently fixed one issue with the API email transports that was failing a test in our Sparkpost plugin: #14661. We need really robust functional tests to cover them all. Because one bug fix may break other workflows and create other bugs. |
Description
This PR makes sure headers specified in email forms to send direct email or segment email (see images below) are respected. Until this bugfix values were properly stored in the database, but they were not used when messages were sent.
I believe this addresses two issues: #14080 and #14483
📋 Steps to test this PR:
Prepare Mautic instance:
Test sending with global config:
Test sending direct message with form config:
Test sending segment message: