Configuring SMTP Mail notifier for Statping
-
I could simply tell you how, but I would like to use this as education. (Sorry it hit you :D)
Where can I find X Information about app Y?
First of all the doc of the app.
In your example: https://docs.cloudron.io/apps/statping/This doc did not help. What now?
Lets go deeper. You know you want the SMTP Setting for the app.
Well let's check out the app on gitlab: https://git.cloudron.io/cloudron/statping-appEvery Cloudron app has a
CloudronManifest.json
lets take a look at the CloudronManifest.json|{ "id": "com.statping.cloudronapp", "version": "1.0.0", "title": "Statping", "tagline": "Web and App Status Monitoring", "website": "https://statping.com/", "contactEmail": "support@cloudron.io", "author": "Statping developers", "healthCheckPath": "/health", "configurePath": "/dashboard", "tags": [ "monitor", "ping", "status", "uptime" ], "httpPort": 8080, "addons": { "localstorage": {}, "postgresql": {}, "sendmail": {} }, "mediaLinks": [ "https://screenshots.cloudron.io/com.statping.cloudronapp/statping01.png", "https://screenshots.cloudron.io/com.statping.cloudronapp/statping02.png" ], "changelog": "file://CHANGELOG", "description": "file://DESCRIPTION.md", "manifestVersion": 2, "postInstallMessage": "file://POSTINSTALL.md", "minBoxVersion": "5.4.0", "capabilities": [ "ping" ], "forumUrl": "https://forum.cloudron.io/category/92/statping", "documentationUrl": "https://docs.cloudron.io/apps/statping", "icon": "file://logo.png" }
We can get from this that the
addons
:localstorage
,postgresql
andsendmail
is used.Let's go back to https://docs.cloudron.io/ and put
addons
in the search, leads to this https://docs.cloudron.io/custom-apps/addons/ where we can view the sendmail addon docs.sendmail
The sendmail addon can be used to send email from the application.
Exported environment variables:
CLOUDRON_MAIL_SMTP_SERVER= # the mail server (relay) that apps can use. this can be an IP or DNS name CLOUDRON_MAIL_SMTP_PORT= # the mail server port. Currently, this port disables TLS and STARTTLS. CLOUDRON_MAIL_SMTPS_PORT= # SMTPS server port. CLOUDRON_MAIL_SMTP_USERNAME= # the username to use for authentication CLOUDRON_MAIL_SMTP_PASSWORD= # the password to use for authentication CLOUDRON_MAIL_FROM= # the "From" address to use CLOUDRON_MAIL_DOMAIN= # the domain name to use for email sending (i.e username@domain)
These are variables which can be echoed in the app web-terminal.
So go to your app web-terminal and do:echo CLOUDRON_MAIL_SMTP_SERVER
You can redo this step for each variable or do:
printenv | grep -i CLOUDRON_MAIL
thanks @brutalbirdie for the "teach a man to fish" breakdown of how best to troubleshoot the app add ons and terminal look up for variables.
I found it helpful. and was able to see the apps SMTP info - HOWEVER, with that info, i was not able to get a successful email out of the app via its SMTP Mail notifier. i tried both ports with and without TLS/SSL.
as of now i have two primary issues when using statping on cloudron
- emails do not appear to be going out
- because i am not getting emails, i cant validate a new users email, which means i cant add new users to get notifications.
Here is the error code (ip masked)
{ "Op": "dial", "Net": "tcp", "Source": null, "Addr": { "IP": "xxx.xxx.xxx.xxx", "Port": 2465, "Zone": "" }, "Err": { "Syscall": "connect", "Err": 111 } }
-
thanks @brutalbirdie for the "teach a man to fish" breakdown of how best to troubleshoot the app add ons and terminal look up for variables.
I found it helpful. and was able to see the apps SMTP info - HOWEVER, with that info, i was not able to get a successful email out of the app via its SMTP Mail notifier. i tried both ports with and without TLS/SSL.
as of now i have two primary issues when using statping on cloudron
- emails do not appear to be going out
- because i am not getting emails, i cant validate a new users email, which means i cant add new users to get notifications.
Here is the error code (ip masked)
{ "Op": "dial", "Net": "tcp", "Source": null, "Addr": { "IP": "xxx.xxx.xxx.xxx", "Port": 2465, "Zone": "" }, "Err": { "Syscall": "connect", "Err": 111 } }
-
@chris please open a new topic about this issue and link this topic to it. (and also me if you wish so)
This way different problems stay separated and also their solutions which makes the solution easier to find in the future.Oh I guess this got moved, good to know
The error code is from the Cloudron Mail tab or from the Statping app?
-
Oh I guess this got moved, good to know
The error code is from the Cloudron Mail tab or from the Statping app?
@brutalbirdie error is from statping backend when adding (and testing) smtp info:
-
@brutalbirdie error is from statping backend when adding (and testing) smtp info:
@chris looks to be some bug in the app. Unfortunately, there are many issues with the app and others have also requested that this app be marked as unstable (https://forum.cloudron.io/topic/4106/mark-this-app-as-unstable/). To add to it, the upstream author is not responding much either about bug reports we raised.
So, I don't have a good answer other than to not use this app for the moment until we find some time to fix the issues. I am looking into publishing phpservermonitor in the next few days (since @msbt has already packaged it).
-
@chris looks to be some bug in the app. Unfortunately, there are many issues with the app and others have also requested that this app be marked as unstable (https://forum.cloudron.io/topic/4106/mark-this-app-as-unstable/). To add to it, the upstream author is not responding much either about bug reports we raised.
So, I don't have a good answer other than to not use this app for the moment until we find some time to fix the issues. I am looking into publishing phpservermonitor in the next few days (since @msbt has already packaged it).
-
@girish i got SMTP working when used with SENDGRID, no problem - so i am not sure this particular issue is a bug with the app (seems not).
Maybe my SMTP settings from cloudron are the issue, any other ideas?
@chris Oh, I just noticed that the SMTP Host is not correct. It should be
mail
and notmy.domain.com
. This is because the port 2465 is only exposed internally and not exposed externally.Can you try these and let me know what works (same username and password as above):
- SMTP Host:
mail
and Port 2465 - SMTP Host:
mail
and Port 2525 - SMTP Host:
my.xx.net
and Port 587 <-- I expect this to definitely work since you say sendgrid worked
BTW, Where did you get the SMTP Username and Password from? Did you just create a mailbox (if so, that is the correct way) or from the environment variables (this is also correct).
- SMTP Host:
-
@chris Oh, I just noticed that the SMTP Host is not correct. It should be
mail
and notmy.domain.com
. This is because the port 2465 is only exposed internally and not exposed externally.Can you try these and let me know what works (same username and password as above):
- SMTP Host:
mail
and Port 2465 - SMTP Host:
mail
and Port 2525 - SMTP Host:
my.xx.net
and Port 587 <-- I expect this to definitely work since you say sendgrid worked
BTW, Where did you get the SMTP Username and Password from? Did you just create a mailbox (if so, that is the correct way) or from the environment variables (this is also correct).
@girish i followed @BrutalBirdie notes from this forum post
running
printenv
from within terminal to see user/pass/port info. let me try your suggested edits now... - SMTP Host:
-
@chris Oh, I just noticed that the SMTP Host is not correct. It should be
mail
and notmy.domain.com
. This is because the port 2465 is only exposed internally and not exposed externally.Can you try these and let me know what works (same username and password as above):
- SMTP Host:
mail
and Port 2465 - SMTP Host:
mail
and Port 2525 - SMTP Host:
my.xx.net
and Port 587 <-- I expect this to definitely work since you say sendgrid worked
BTW, Where did you get the SMTP Username and Password from? Did you just create a mailbox (if so, that is the correct way) or from the environment variables (this is also correct).
- SMTP Host:
-
@girish no luck with any of those 3 approaches. all failed with the app, reverted back to send grid for now.
@chris thanks for testing. I found the reason why it won't connect to port 587. It's because when a connection is "internal", Cloudron won't offer STARTTLS. This makes Go reject the connection as unencrypted. This is the reason why we had made port 2465 in the first place but that doesn't work for some reason. Debugging...
-
@chris thanks for testing. I found the reason why it won't connect to port 587. It's because when a connection is "internal", Cloudron won't offer STARTTLS. This makes Go reject the connection as unencrypted. This is the reason why we had made port 2465 in the first place but that doesn't work for some reason. Debugging...
@girish thanks for looking deeper into this, hopefully the fix is easy.
while testing various SMTP out configs, i also thought i would integrate twilio, i already have twilio accounts, so putting in the Account SID and Token was easy, and worked, but when i put the phone number in and saved, i got an error, status code 422. will open new forum post on this one to keep this one related to SMTP.
-
OK, decided to look into this to see if it's something obvious.
The testing logic is here https://github.com/statping/statping/blob/1a56afe7f76403ad8f839a45de02b2715370eb6c/notifiers/email.go#L137 which in turn just calls into https://github.com/statping/statping/blob/1a56afe7f76403ad8f839a45de02b2715370eb6c/notifiers/email.go#L155 . By my reading, SSL will be set to false (ApiKey is curious use of some random db field it seems). Which then lands in an unmaintained go module - https://github.com/go-mail/mail/blob/v2/smtp.go . The default for StartTLS in the package is opportunistic - https://github.com/go-mail/mail/blob/v2/smtp.go#L163 , so it should all just work but clearly doesn't
-
OK, decided to look into this to see if it's something obvious.
The testing logic is here https://github.com/statping/statping/blob/1a56afe7f76403ad8f839a45de02b2715370eb6c/notifiers/email.go#L137 which in turn just calls into https://github.com/statping/statping/blob/1a56afe7f76403ad8f839a45de02b2715370eb6c/notifiers/email.go#L155 . By my reading, SSL will be set to false (ApiKey is curious use of some random db field it seems). Which then lands in an unmaintained go module - https://github.com/go-mail/mail/blob/v2/smtp.go . The default for StartTLS in the package is opportunistic - https://github.com/go-mail/mail/blob/v2/smtp.go#L163 , so it should all just work but clearly doesn't
Thanks for taking another look into this @girish - the maintainer seems unwilling/unable to address the issue you raised on github. For now using a third party SMTP is working fine with this app (sendgrid) but i would love if this apps twilio support (SMS) support, worked... as its tands i cant get that working either. in any case, looking into the new app on cloudron you just added: https://forum.cloudron.io/category/126/php-server-monitor as it providers similar features.
-
After much Go code spelunking:
I guess a fix has to be made to statping but generally I prefer changing the platform to adapt to the app unless it's an outright bug. So, I am going to see if I can fix our mail server.
Notes to future me:
- statping always sets mailer.SSL to fase. This means port 2465 can never work
- Ultimately, go-mail in turn uses net/smtp which won't send passwords with TLS