Skip to content
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

Feature: Test Mail aus Backend versenden #1469

Closed
contaoacademy opened this issue Apr 9, 2018 · 6 comments
Closed

Feature: Test Mail aus Backend versenden #1469

contaoacademy opened this issue Apr 9, 2018 · 6 comments

Comments

@contaoacademy
Copy link

contaoacademy commented Apr 9, 2018

Es wäre hilfreich, wenn man per Klick eine Test-Mail versenden könnte um zu überprüfen, ob die SMTP-Einstellungen korrekt gesetzt sind bzw. ob der Server die Mails versenden kann.

Kann gerne unter System-Wartung sein oder evtl. ist das auch besser im Contao Manager aufgehoben.

@Toflar
Copy link
Member

Toflar commented Apr 9, 2018

Das müsste in den Manager, weil es eine Kommandozeilen-Operation ist:

vendor/bin/contao-console swiftmailer:email:send --help

@aschempp
Copy link
Member

Ich hätte etwas bedenken über den Manager freien E-Mail Versand zu erlauben. Würde es reichen wenn eine definierte E-Mail an den Systemadmin versendet werden kann?

@Toflar
Copy link
Member

Toflar commented Apr 10, 2018

Naja, du musst ja eingeloggt sein. Aber vordefiniert einfach als Testmail, ist sicher eine gute Option. Das würde ja die Anforderung abdecken :)

@leofeyer
Copy link
Member

Kann ich das Ticket dann zum Manager verschieben?

@aschempp
Copy link
Member

aschempp commented Apr 10, 2018 via email

@ghost
Copy link

ghost commented Apr 12, 2018

Das Ticket wurde nach contao/contao-manager#254 verschoben.

@ghost ghost closed this as completed Apr 12, 2018
leofeyer pushed a commit that referenced this issue Jul 1, 2020
Description
-----------

This PR replaces the usage of `symfony/swiftmailer-bundle` with `symfony/mailer`. It serves as a basis for a follow-up PR for the available mailer selection based on the [Symfony Mailer Component](https://symfony.com/doc/4.4/mailer.html) (which would replace the existing draft #1469 based on the Swiftmailer Bundle).

The switch is pretty straight forward actually. However there are some things to consider which I will comment on in the files view.

Commits
-------

38ae8916 switch to symfony/mailer
f7ac5f48 make port optional
d3243e2f change MAILER_DSN back to MAILER_URL
73a7fd55 dynamically add default mailer
6ddec29e fix code style
d820da6a add \Swift_Mailer fallback
c7934488 fix automatic embedding of images
525dfd6b add comment
db5e1ba7 use MAILER_DSN with MAILER_URL fallback
193821a4 remove Email deprecation
44536cd6 allow query options from MAILER_URL
c905ddc4 increase symfony/mailer dependency
8906865b add comment about why we add default mailer dynamically
399d6b5b add comment about the gmail transport
21983dc5 add invalid argument exception
58214473 code style fix
3981e8c8 update dependencies
181a9c38 update dependencies
c8b8f427 update dependencies
aa46267b only allow Symfony 4.4
leofeyer added a commit that referenced this issue Jul 17, 2020
Description
-----------

| Q                | A
| -----------------| ---
| Fixed issues     | Fixes #1613
| Docs PR or issue | contao/docs#465

_Note:_ this PR depends and is based on #1829. It will be rebased, once #1829 got merged.

This is the alternative version of #1469, based on the [Symfony Mailer Component](https://symfony.com/doc/4.4/mailer.html) instead of the Swiftmailer Bundle. It makes the configured `framework.mailer.transports` selectable in the back end. Example:

```yml
# config/config.yml
framework:
  mailer:
    transports: 
      app: smtps://[email protected]:[email protected]:465
      page: smtps://[email protected]:[email protected]:465
      forms: smtps://[email protected]:[email protected]:465
      newsletter: smtps://[email protected]:[email protected]:465

contao:
  mailer:
    transports:
      page: ~
      forms: ~
      newsletter: ~
```

<img src="https://user-images.githubusercontent.com/4970961/84607561-e3a06d00-aea5-11ea-9f89-daac495b8a85.png" alt="mailer_transport_01" width="576">

_Note:_ only the transports configured in `contao.mailer.transports` will be available for selection.

You can also provide translations:

```yml
# translations/mailer_transports.en.yml
page: 'Page'
forms: 'Forms'
newsletter: 'Newsletters'
```

<img src="https://user-images.githubusercontent.com/4970961/84607577-f7e46a00-aea5-11ea-9cd1-59271843609b.png" alt="mailer_transport_02" width="576">

And you can override the `From` address for each transport in the Contao configuration:

```yml
contao:
  mailer:
    transports:
      page:
        from: Contao Page <[email protected]>
      forms:
        from: Contao Forms <[email protected]>
      newsletter:
        from: Contao Newsletter <[email protected]>
```

<img src="https://user-images.githubusercontent.com/4970961/84607478-670d8e80-aea5-11ea-9bdd-1cb2b090fd5a.png" alt="mailer_transport_03" width="576">

_Note:_ only the transports configured in `contao.mailer.transports` will be available for selection.

Using the Symfony Mailer Component for this seems more elegant to me, since it requires no change whatsoever in the `\Contao\Email` class ([see the comparison](fritzmg/contao@feature/symfony-mailer...feature/available-symfony-mailers)). With the Symfony Mailer Component, the transport to be used is simply chosen with an `X-Transport` header in the email message itself.

This PR decorates the `mailer` service and automatically sets an `X-Transport` header based on the website root settings - and automatically overrides the `From` address based on the chosen transport.

Commits
-------

fd3da56a switch to symfony/mailer
6c21d672 change MAILER_DSN back to MAILER_URL
eeaea321 dynamically add default mailer
6ad300c4 add \Swift_Mailer fallback
71a5553a use MAILER_DSN with MAILER_URL fallback
cc348243 remove Email deprecation
8c2480a7 increase symfony/mailer dependency
39267663 switch to symfony/mailer
3fd2799c dynamically add default mailer
43aa11c3 provide mailer transport selection and from override
c38e8646 add missing model property
8cee6db5 fix AvailableTransportsTest
08c9b201 fix code style
a8d9b591 fix yml style
ca478014 only show configured mailer transports within Contao
e4f774f6 change translation domain
1722e810 restore previous version requirement
21b55d24 code style fix
1abfc387 rename mailer_transport DCA field to mailerTransport
af8563c3 use Annotations for mailerTransport options callback
058da895 implement some early outs
4585e9dd add missing model methods
a2da52c8 fix code style
f8020035 Merge remote-tracking branch 'origin/master' into feature/available-symfony-mailers
a5d7c747 add more unit tests
94203d73 use assertSame
38c3de95 improve testAnnotatedCallbacks test
3ca8e024 Rearrange the form fields in the back end
33f38c43 add missing methods
b7159fe0 change wording to 'mailer transport'
ba4f4232 merge with master
b8ffb367 Apply suggestions from code review

Co-authored-by: Leo Feyer <[email protected]>
This issue was closed.
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

No branches or pull requests

4 participants