Best way to implement backup SMTP connection
Forum rules
Always add your Laravel, Aimeos and PHP version as well as your environment (Linux/Mac/Win)
Spam and unrelated posts will be removed immediately!
Always add your Laravel, Aimeos and PHP version as well as your environment (Linux/Mac/Win)
Spam and unrelated posts will be removed immediately!
Best way to implement backup SMTP connection
We have had issues with our SMPT provider failing and want to establish a backup account to send emails when needed.
What would be the best way to implement it?
I'm looking in to extending the SwiftMailer classes, but have run in to issues with passing the message in.
Argument 1 passed to Swift_Transport_AbstractSmtpTransport::send() must be an in stance of Swift_Mime_SimpleMessage, instance of Aimeos\MW\Mail\Message\Swift given.
Bottom line is we want to be able to just use different SMPT credentials should the main ones fail.
What would be the best way to implement it?
I'm looking in to extending the SwiftMailer classes, but have run in to issues with passing the message in.
Argument 1 passed to Swift_Transport_AbstractSmtpTransport::send() must be an in stance of Swift_Mime_SimpleMessage, instance of Aimeos\MW\Mail\Message\Swift given.
Bottom line is we want to be able to just use different SMPT credentials should the main ones fail.
Re: Best way to implement backup SMTP connection
You can implement a decorator (a wrapper class with the same interface, like an onion) that calls the underlying ai-swiftmailer class and if it throws an exception, send the e-mail to an alternative provider. Additonally, you have to extend the Aimeos context object and add your decorator instead of the Laravel Swiftmailer object here:
https://github.com/aimeos/aimeos-larave ... #L180-L185
https://github.com/aimeos/aimeos-larave ... #L180-L185
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, give us a star
If you like Aimeos, give us a star
Re: Best way to implement backup SMTP connection
Thank you,
So far I extended:
vendor\aimeos\aimeos-laravel\src\Aimeos\Shop\Base\Context.php
vendor\aimeos\aimeos-core\lib\mshoplib\src\MShop\Context\Item\Iface.php
vendor\aimeos\aimeos-core\lib\mshoplib\src\MShop\Context\Item\Standard.php
to have a getMailBackup() and SetMailBackup(). The entire site is getting a 500 in the browser without any logs in the storage/logs or madmin_log table.
I'm not sure which files I missed to add the extension.
So far I extended:
vendor\aimeos\aimeos-laravel\src\Aimeos\Shop\Base\Context.php
vendor\aimeos\aimeos-core\lib\mshoplib\src\MShop\Context\Item\Iface.php
vendor\aimeos\aimeos-core\lib\mshoplib\src\MShop\Context\Item\Standard.php
to have a getMailBackup() and SetMailBackup(). The entire site is getting a 500 in the browser without any logs in the storage/logs or madmin_log table.
I'm not sure which files I missed to add the extension.
Re: Best way to implement backup SMTP connection
Wrong way. You should:
- Extend the swiftmailer class and overwrite the send() method to resend the e-mail with an alternative SMTP configuration in case of an error
- Use that class in a Laravel ServiceProvider to create the "mailer" object
Thus, you don't need to change anything in Aimeos but only create a Laravel ServiceProvider and your own Swiftmailer class.
- Extend the swiftmailer class and overwrite the send() method to resend the e-mail with an alternative SMTP configuration in case of an error
- Use that class in a Laravel ServiceProvider to create the "mailer" object
Thus, you don't need to change anything in Aimeos but only create a Laravel ServiceProvider and your own Swiftmailer class.
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, give us a star
If you like Aimeos, give us a star