Protonmail SMTP working? 422 errors

Version ie <v5.11.17>

Environment <Ubuntu 24 EC2>

Checklist

-Opened ports with EC2 instance
-Already tried with other stmp email server, that’s working
-jumped through the hoops with protonmail to get the domain cname, mx etc. all working
-updated php artisan optimize, etc.
-have endered the data manually in the .env file, not working
-tried TLS, and STARTTLS

  • I have seen the error with other threads, but advice has not solved the issue.

Describe the bug

When trying
""422: The given data was invalid.
• The smtp username field is required.
• The smtp password field is required.
“”

Steps To Reproduce

-set up smtp email with protonmail and use port 587 and STARTLS, collect token
-enter token information into email settings, and save
-try to send test email

Expected Behavior

Successful email sent.

Additional context

If this is some bs with aws Ec2 port 587 firewall i’m gonna shit.

Screenshots

Logs

Hi,

Are you using the web app or the desktop app? It may help to try the other.

I am on the Flutter Web app, I have yet to get the React app working yet on my self-hosted server.

Have you tried setting the credentials in the app on Settings > Email Settings?

Yes, that’s where I am having trouble.

I tried converting back to my other stmp server on port 465, however the email settings were not updating after saving in Settings > Email Settings, then optimizing with php.

Email, with the old smtp server is working with a manual edit of .env, then sending out a client email invoice, however sending test email still fails in Settings >Email Settings.

doesn’t update .env file, when saving, probably due to permission error. I am not sure if there is a temp file that is created somewhere in the DB. It would be nice to have multiple email settings to select between two, or three addresses stored.

When you save the SMTP settings on Settings > Email Settings it’s stored in the database, you won’t see any changes in the .env file.

Even so, utilizing TLS settings from gmail works with editing the .env file.
However for proton:

MAIL_MAILER=smtp
MAIL_PORT=587
MAIL_ENCRYPTION=“STARTTLS”
MAIL_HOST=“smtp.protonmail.ch”
MAIL_USERNAME=“myusername@mydomain”
MAIL_FROM_NAME=“”
MAIL_FROM_ADDRESS=“my-email@mydomain”
MAIL_PASSWORD=“my-smtp-token”

These settings still do not work.

php artisan optimize && php artisan config:clear , don’t do anything.

Edit:
This may be and EC2 issue, thanks for your help

Are you filling in all fields?

Yes, I have tried filling all the fields.

I did try some troubleshooting with openssl and the smtp.protonmail.ch client.
As far as I can tell it uses AUTH PLAIN. Not sure if this is in the working code yet or not.

Similar problem and fix: 535 5.7.8 Error: authentication failed: Invalid authentication mechanism - Technical Problems - Invision Community

After turning on EXPANDED_LOGGING=true to .env

It looks like the headers are getting sent with the registered gmail account, which was used to set up the server, and not accepting the new email settings. I also tried to add the @proton.ch email as admin under user management as well, but to no avail…

/storage/logs/invoiceninja.log
[2025-01-14 00:08:33] production.INFO: Mailer failed with a Transport Exception Expected response code “250/251/252” but got code “553”, with message “553 5.7.1 <[email-protected]@gmail.com>: Sender address rejected: not owned by user [email-protected]@proton.ch”.
[2025-01-14 00:09:09] production.INFO: Using mailer => smtp 2025-01-14 00:09:09
[2025-01-14 00:09:10] production.INFO: Mailer failed with a Transport Exception Expected response code “250/251/252” but got code “553”, with message “553 5.7.1 <[email-protected]@gmail.com>: Sender address rejected: not owned by user [email-protected]@proton.ch”.

I suggest asking in a discussion on GitHub

So I figured out settings to get the emails working:

.env file mail settings permissions inherit from email data in
User Details

As long as these two emails are the same in, .env and User Details, sending invoice emails works.

However, I still get the same 422 errors, with the ‘Send Test Email Button’ with the working smtp.protonmail.ch settings in email settings , concurrently. Go figure.