10000 [Mailer] AbstractTransport silently doing nothing if no recipients set · Issue #35805 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content
8000

[Mailer] AbstractTransport silently doing nothing if no recipients set #35805

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

Closed
jschaedl opened this issue Feb 20, 2020 · 2 comments
Closed

Comments

@jschaedl
Copy link
Contributor
jschaedl commented Feb 20, 2020

Today I struggled a bit with sending an email via the Mailer class.

Here is some example code of what tried to do:

$email = (new Email())
    ->from('test@test.de')
    ->subject('Subject')
    ->text('Content')
;

$this->mailer->send($email);
# .env
MAILER_DSN=smtp://localhost:1025

The implementation and the mailer configuration looked fine to me, but the email was not send out. There was also no Exception that indicated what I probably did wrong.

So I debugged my code and could find this line in the AbstractTransport.

https://github.com/symfony/symfony/blob/master/src/Symfony/Component/Mailer/Transport/AbstractTransport.php#L68

As you can see the AbstractTransport::send() method is just returning null in case there are no recipients set, which means the transport is failing "silently" without sending the email. Ok, my bad, I forgot to set a recipient. Problem solved.

But I was wondering, if this is intended behaviour? I actually would have expected an Exception telling me that I forgot to set a recipient.

@jschaedl jschaedl changed the title [Mailer] AbstractTransport silently doing nothing if no reciepents set [Mailer] AbstractTransport silently doing nothing if no recipients set Feb 20, 2020
@noniagriconomie
Copy link
Contributor
noniagriconomie commented Feb 21, 2020

@jschaedl I got this also when trying the component back then

maybe adding a log info, notice or warning could be usefull wdyt?

as there is a $this->logger available :)

edit: I opened a PR for this

@jschaedl
Copy link
Contributor Author
jschaedl commented Feb 21, 2020

Duplicate of #33753

fabpot added a commit that referenced this issue Apr 16, 2020
This PR was merged into the 4.4 branch.

Discussion
----------

Mailer from sender fixes

| Q             | A
| ------------- | ---
| Branch?       | 4.4
| Bug fix?      | yes
| New feature?  | no <!-- please update src/**/CHANGELOG.md files -->
| Deprecations? | no <!-- please update UPGRADE-*.md and src/**/CHANGELOG.md files -->
| Tickets       | Fix #35818, Fix #35805, Fix #33753 | License       | MIT
| Doc PR        | n/a

Commits
-------

e885860 Fix From/Sender handling in Emails
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants
0