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

Mailversand über Swiftmailer, Sendmail command ändern? #1261

Closed
pressi opened this issue Jan 29, 2020 · 10 comments
Closed

Mailversand über Swiftmailer, Sendmail command ändern? #1261

pressi opened this issue Jan 29, 2020 · 10 comments

Comments

@pressi
Copy link

pressi commented Jan 29, 2020

Hallo,

seit Contao 4.8 funktioniert auf meiner Webseite der Emailversand nicht mehr.
Nach langer Suche und Zusammenarbeit mit dem Hosting Support bin ich auf den Fehler gestoßen.
Beim Swiftmailer SendmailTransport ist diese 'command' => '/usr/sbin/sendmail -bs' hinterlegt.
Damit es bei mir am Hosting funktioniert müsste aber '/usr/sbin/sendmail -t -i' hinterlegt werden.

Meine Frage, wo und wie kann das geändert werden?
Auch so das es update sicher ist.

Danke & LG

@bytehead
Copy link
Member

Du müsstest wohl deinen eigenen Mailer (Service) konfigurieren:

// Create the Transport
$transport = new Swift_SendmailTransport('/usr/sbin/sendmail -t -i');

// Create the Mailer using your created Transport
$mailer = new Swift_Mailer($transport);

@pressi
Copy link
Author

pressi commented Jan 29, 2020

Du müsstest wohl deinen eigenen Mailer (Service) konfigurieren:

// Create the Transport
$transport = new Swift_SendmailTransport('/usr/sbin/sendmail -t -i');

// Create the Mailer using your created Transport
$mailer = new Swift_Mailer($transport);

OK, derzeit werden die Emails über das Notifictaion Center verschickt, wie stelle ich das hier ein?

Ich dachte es gibt eventuell eine globale Einstellung.
Da es über die Contao Email Klasse sowie über das Notification Center nicht funktioniert.

@bytehead
Copy link
Member

Du müsstest den Service mailer überschreiben/decoraten mit deiner angepassten Version: https://symfony.com/doc/current/service_container/service_decoration.html

@pressi
Copy link
Author

pressi commented Jan 29, 2020

Du müsstest den Service mailer überschreiben/decoraten mit deiner angepassten Version: https://symfony.com/doc/current/service_container/service_decoration.html

Danke für die Info, kannst du mir bitte ein Beispiel geben, habe ein Service noch nie überschrieben in Contao.

@ausi
Copy link
Member

ausi commented Jan 30, 2020

Contao überschreibt bzw. decorated z. B. den translator service von Symfony als Beispiel:

contao.translation.translator:
class: Contao\CoreBundle\Translation\Translator
decorates: translator
arguments:
- '@contao.translation.translator.inner'
- '@contao.framework'

@pressi
Copy link
Author

pressi commented Jan 31, 2020

Contao überschreibt bzw. decorated z. B. den translator service von Symfony als Beispiel:

contao.translation.translator:
class: Contao\CoreBundle\Translation\Translator
decorates: translator
arguments:
- '@contao.translation.translator.inner'
- '@contao.framework'

Super Danke!
Jetzt hab ich es gecheckt und es funktioniert, wäre es nicht einfacher wenn diese Email 'command' über die Einstellungen (config.yml oder so) veränderbar wäre?
Oder wäre das gar nicht möglich?

Bei einem anderen Hostinganbieter funktioniert der Email versandt ohne das ich etwas ändern muss, auf diesem aber leider nicht.
Den Fehler zu finden war nicht einfach, da am Hosting auch in keiner Log-Datei Fehler angezeigt wurden, es wurden nur alle E-Mail Adressen abgelehnt, sichtbar im Contao System-Log.

@bytehead
Copy link
Member

Eine weitere Möglichkeit wäre, die Standardkonfiguration des Services mailer zu ändern:

 php bin/console config:dump-reference swiftmailer
# Default configuration for extension with alias: "swiftmailer"
swiftmailer:
    default_mailer:       ~
    mailers:

        # Prototype
        name:
            url:                  null
            transport:            smtp
            command:              '/usr/sbin/sendmail -bs'
            username:             null
            password:             null
            host:                 localhost
            port:                 null
            timeout:              30
            source_ip:            null
            local_domain:         null
            stream_options:       []
            encryption:           null
            auth_mode:            null
            sender_address:       ~
            delivery_addresses:   []
            antiflood:
                threshold:            99
                sleep:                0
            logging:              true
            spool:
                type:                 file
                path:                 '%kernel.cache_dir%/swiftmailer/spool'

                # Used by "service" type
                id:                   null
            delivery_whitelist:   []
            disable_delivery:     ~

Laut https://symfony.com/doc/current/reference/configuration/swiftmailer.html#command müsste sich command anpassen lassen :)

@xstable
Copy link

xstable commented Aug 27, 2020

@pressi Könntest du kurz genauer beschreiben, wie du das Problem nun gelöst hast?
Welche Datei hast du wie angepasst?

@fritzmg
Copy link
Contributor

fritzmg commented Aug 27, 2020

@xstable in Contao 4.4 und 4.9 zB so:

# config/config.yml
swiftmailer:
    mailers:
        default:
            transport: sendmail
            command: '/usr/sbin/sendmail -t -i'

In Contao 4.10 geht das aktuell leider nicht. Siehe symfony/symfony#37432

In Symfony 5.2 wird es aber einen native://default Mailer Transport geben, mit dem die PHP Konfiguration genommen wird. Also das sendmail Kommando, welches in der php.ini eingetragen ist (bzw. unter Windows die entsprechende SMTP Konfiguration): symfony/symfony#36131. Siehe auch #2164.

@fritzmg
Copy link
Contributor

fritzmg commented Sep 28, 2020

If you update symfony/swiftmailer-bundle to version 3.5.0 (won't be possible for Contao 4.4 iirc) then the sendmail command will be automatically retrieved from the sendmail_path PHP configuration value.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 18, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants