-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
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
Introduce a mailer interface and the respective factory #40560
Conversation
I don't think this is the correct implementation for this. Note that factory doesn't actually set the mailer into it's list of statics - all it's doing is populating the data from JApplication. Funnily enough as things stand if all applications only called This is a much simpler case than the mvc classes. I think you just need an interface on the mail class and on top of that a new method in the application that bootstraps a mail instance that can be injected. This will also make the application dependent code much easier to unit test and from the models perspective it makes no diference anyhow whether that bootstrap of the from sender etc has actually taken place or not when the mail object is being injected. |
More or less I was there at the beginning. Then I though that mostly you want to have the settings in the mailer instance from the global config.
This is not correct, it calls
Please no more functions which do make the application instance an even bigger god object. |
This was what I was trying to say - just badly!
OK but what is the value of having that central object stored in the container? Like the container is there to do dependency management not configuration of objects
OK Then put it in JConfiguration as the only alternative - which is where all the variables come from. I don't see any benefit in the abstraction your providing... |
Only the factory is in the container, not the mailer instance. |
Does it work without the patch? Just want to make sure that the settings itself do work. |
Yeah, I tried without the patch first, that worked, then with patch applied and finally with patch removed. Only with applied patch no luck. This is the latest nighly build on PHP 8.2.1. |
Did you try with the send test mail button? |
It says 'Send a test mail while editing the global Joomla configuration.' |
Co-authored-by: heelc29 <[email protected]>
Co-authored-by: heelc29 <[email protected]>
Co-authored-by: heelc29 <[email protected]>
Co-authored-by: heelc29 <[email protected]>
Co-authored-by: heelc29 <[email protected]>
I have now re-tested this successfully on a test site, using SMTP mail on PHP 8.2 |
I have tested this item ✅ successfully on a4df9b9 This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/40560. |
I have tested this item ✅ successfully on a4df9b9 This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/40560. |
RTC This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/40560. |
ParamSignatureMismatch of
|
Co-authored-by: heelc29 <[email protected]>
Co-authored-by: heelc29 <[email protected]>
Co-authored-by: heelc29 <[email protected]>
Then phan messages can be ignored for now as the interface should be decoupled from the actual Mail implementation. Till the interface gets wider acceptance and we can change the methods in mailer we have to leave with the mismatch. PHP itself is accepting that and this is what counts for me at the moment. The target is to have an independent mailer interface without any reference to an implementation so we can exchange it on some point when there is a need for it. |
Summary of Changes
Introduces a new
MailerInterface
which does contain the most common functions which are needed to send a mail. A factory which is served through the container and the corresponding aware interface and trait are also shipped with this pr.It also fixes an inconsistency, getting a mailer with the global configuration settings.
Mail::getInstance()
delivers the same object, but with a different configuration, either ifFactory::getMailer()
is called before or not. Here is an example:With this pr all calls do return as From value the EMail address from the global configuration.
Testing Instructions
Send a test mail while editing the global Joomla configuration.
Actual result BEFORE applying this Pull Request
Test mail is sent.
Expected result AFTER applying this Pull Request
Test mail is sent.
Link to documentations
Please select:
Documentation link for docs.joomla.org:
No documentation changes for docs.joomla.org needed
Pull Request link for manual.joomla.org: Add documentation for the new mailer interface Manual#116
No documentation changes for manual.joomla.org needed