bertvandepoel / tabby

A friendly tool to manage debt
GNU Affero General Public License v3.0
70 stars 11 forks source link

Switch from default mail function to PHPMailer #22

Open realjoshparker opened 2 years ago

realjoshparker commented 2 years ago

I've been looking into ways of getting emails to work in the docker container. I propose that you switch from using the default mail function in php to using something more robust like PHPMailer. From what I've been able to gather online the default function doesn't allow you to do authentication with an external SMTP server. PHPMailer allows for things like SMTP authentication and I think it would make using the container much easier and attainable for most users.

I also think it'd be a good switch because many ISPs that I know of in the USA block email for most plans so allowing for use of external SMTP servers would be very beneficial in those cases. With this switch I'd be able to have users enter this information as environment variables when starting the container making it easy to configure and change in the future.

bertvandepoel commented 2 years ago

I had been under the impression that the php.ini variables for an SMTP server and auth were generally available, but they seem to be restricted to the fake sendmail on Windows, so that's indeed a problem. Technically there's the option of having a sendmail compatible client that relays to an SMTP server with out. There's several pieces of open source software that do that, but I believe this would be a difficult task for many and doesn't solve the issues with the ISPs you describe, where you of course can't go and install something like that.

Are there specific reasons why you chose PHPMailer over PEAR's Mail.php? I tend to go with the latter, but I'm not sure if it's nowadays still installed at most hosting providers. It used to be widely available. I prefer Mail.php since then the responsibility lies with the ISP/distro to deal with security issues, while with PHPMailer I would myself need to keep track of any security issues with PHPMailer (of which there have been a few over the years). Either way I would also have to update the installer to offer the SMTP option in more detail.

realjoshparker commented 2 years ago

No there’s no specific reasoning I just saw it mentioned a number of times on forums while I was researching ways to add external SMTP servers. I’d be happy with any solution you propose!

PrplHaz4 commented 2 years ago

I've seen popular frameworks (Laravel, Yii) are going with Symfony Mailer now (successor to Swiftmailer), which means it will likely be maintained for some time and will take security issues seriously.

https://symfony.com/doc/current/mailer.html

realjoshparker commented 1 year ago

Hey, sorry for the long time with no update, I've just been real busy and didn't have too much time to devote to this project. Thanks to ChatGPT I think I finally have a solution that will work for both of us. I figured out I can use something called sSMTP which can act like sendmail but proxy out to external servers. I believe I have a working container I just have to test it. I'm also working on updating the docs to reflect these changes and will hopefully have it tested and pushed out by the end of next week.

bertvandepoel commented 1 year ago

I use ssmtp on my NAS I think, not sure though. I should really invest some time in adding SMTP support, but I've been swamped with my new job and volunteer stuff that takes priority. I'm still hoping to get back to Tabby to add SMTP support as well as EPC QR codes and some other extras that people have requested.