Email configuration
Closed this issue · 5 comments
Hi,
I installed PIA backend and frontend with authentication. Debian 11 using Apache2.
Everything works well, except that i can't get pia-back to send emails.
Postfix is installed and working. I tried sending the mail as user www-data and got the mail without problems.
echo "This is the body of the email" | mail -s "This is the subject line" test@xxxxx.xxx
But i do not receive any emails from PIA. The below example is when i user "Récupération du mot de passe":
pia-back access.log:
10.24.0.240 - - [24/Jan/2023:10:27:28 +0100] "OPTIONS /users/password-forgotten HTTP/1.1" 200 3516 "https://pia.xxx.xxx/" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/16.2 Safari/605.1.15"
10.24.0.240 - - [24/Jan/2023:10:27:28 +0100] "POST /users/password-forgotten HTTP/1.1" 500 510 "https://pia.xxx.xxx/" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/16.2 Safari/605.1.15"
10.24.0.240 - - [24/Jan/2023:10:27:35 +0100] "-" 408 3047 "-" "-"
Nothing in mail.log except:
Jan 24 10:19:49 pia postfix/smtpd[6372]: connect from localhost[::1]
Jan 24 10:19:49 pia postfix/smtpd[6372]: disconnect from localhost[::1] ehlo=2 starttls=1 quit=1 commands=4
.env file in pia-back root:
MAILER_SENDER=noreply@pia.xxx.xxx
DEFAULT_URL=https://pia.xxx.xxx
DEFAULT_PORT=443
production.log:
[403b31df-1621-41a0-a7c9-1fc91441fdc4] ArgumentError (SMTP From address may not be blank: nil):
Do i need to configure anything more ? Why is the from address blank, shouldn't it use the MAILER_SENDER env variable?
Thanks for any hint / doc that could help.
Hello @Foxi352,
We just merged the rails7 branch to the main branch.
Same for "pia" https://github.com/LINCnil/pia with some fixes.
Regarding the SMTP configuration you need to update the information inside: https://github.com/LINCnil/pia-back/blob/master/config/initializers/mailer.rb
The wiki is not updated for now, but you need to set your SMTP credentials in this file.
We can help you if needed.
Thanks for your reply. I am new to ruby so updating pia-back, rails and gem's was not that easy :-)
Pia was easier as i have Angular experience.
I now have latest versions of pia and pia-back running.
Re mail: If i edit mailer.rb directly, will that not make problems on future git pull
?
Can i use EDITOR='nano' bin/rails credentials:edit
and put something in there like:
smtp_address: srvexchange.xxx.xxx
smtp_post: 587
smtp_authentication: false
smtp_enable_starttls_auto: true
Or where does it get it's Rails.application.credentials.smtp_address
from ?
Yes it's better to update the credentials with EDITOR='nano' bin/rails credentials:edit
and set the value inside.
I still get the error production.log
:
F, [2023-02-01T14:23:20.526919 #229398] FATAL -- : [b7a116d1-c259-4c59-88bb-315d554eab29]
[b7a116d1-c259-4c59-88bb-315d554eab29] ArgumentError (SMTP From address may not be blank: nil):
[b7a116d1-c259-4c59-88bb-315d554eab29]
[b7a116d1-c259-4c59-88bb-315d554eab29] app/controllers/users_controller.rb:70:in `password_forgotten'
In .env
:
MAILER_SENDER=noreply@pia.xxx.xxx
In EDITOR='nano' bin/rails credentials:edit
:
smtp_address: srvexchange.xxx.xxx
smtp_post: 587
smtp_authentication: false
smtp_enable_starttls_auto: true
Did i miss something ?
Hi @Foxi352 sorry for the late answer.
You need to add email_from
into the credentials.
You have more information in the README