Monica: SMTP setup and logging

Created on 2 Jun 2018  路  22Comments  路  Source: monicahq/monica

I have no success in setting up the connection to a mail server. Currently I am using the docker image and my biggest problem is that i am not able to configure any helpful logging that could give me an idea what wents wrong or if at least the mail server gets contacted.

i tried:
APP_ENV = local
APP_DEBUG = true
inspected the logs created in storage and the docker logs

Currently i am trying to trigger emails with the new email doubleopt in feature.

Anyone has for instance a running gmail setup that i can give a tried (i also tried the usual 587 / smtp.gmail.com / tls setup with no success)

I also tried MAIL_DRIVER=log what unfortunately does not add anything to the logs in my case.

Is there any chance to enable some kind of logging?

Thanks,
Sebastian

documentation priority support

Most helpful comment

Monica is just using lavarel framework for sending email. So, you can just look up docs in lavarel.

I was debugging this for the Monica app on Cloudron. Adding MAIL_DRIVER=log does put the emails in storage/logs/lavarel.log.

On Cloudron, we have a built-in SMTP server. The combination that works for us is:

# Mail credentials used to send emails from the application.
MAIL_DRIVER=smtp
MAIL_HOST=mail # this is the internal host name
MAIL_PORT=2525 # internal STARTTLS port
MAIL_USERNAME=${MAIL_SMTP_USERNAME}
MAIL_PASSWORD=${MAIL_SMTP_PASSWORD}
MAIL_ENCRYPTION= # Since it's internal, we don't use encryption on Cloudron
MAIL_FROM_ADDRESS=${MAIL_FROM}
MAIL_FROM_NAME=Monica

Hope that helps someone.

All 22 comments

Same issue for me, without logs I am unable to troubleshoot.

Likewise. There is absolutely no documentation for anything that relates to mailing.

Monica is just using lavarel framework for sending email. So, you can just look up docs in lavarel.

I was debugging this for the Monica app on Cloudron. Adding MAIL_DRIVER=log does put the emails in storage/logs/lavarel.log.

On Cloudron, we have a built-in SMTP server. The combination that works for us is:

# Mail credentials used to send emails from the application.
MAIL_DRIVER=smtp
MAIL_HOST=mail # this is the internal host name
MAIL_PORT=2525 # internal STARTTLS port
MAIL_USERNAME=${MAIL_SMTP_USERNAME}
MAIL_PASSWORD=${MAIL_SMTP_PASSWORD}
MAIL_ENCRYPTION= # Since it's internal, we don't use encryption on Cloudron
MAIL_FROM_ADDRESS=${MAIL_FROM}
MAIL_FROM_NAME=Monica

Hope that helps someone.

For linux servers the maillog is located at /var/log/maillog. that should give you any messages related to smtp deliveries and such.

@sfeu did you find a workaround?

I am also encountering this issue. The reminders are being created, and then deleted when I run send:reminders, but there is no email. I've tried Mailtrap and MAIL_DRIVER=log. Nothing at all. No errors anywhere. The Unit Tests even pass. I am at a complete loss about what to try next. I'd be happy if I could get even the barest sort of logging so I can troubleshoot.

@tbirrell Which server are you running it on? Linux? Windows? Oracle? For CentOS/Fedora/Any Flavor RHEL the log to see if any email is actually being sent is /var/log/maillog, also check to make sure you have postfix/sendmail installed/running.

@samjaninf, Ubuntu on Digital Ocean. I can send email from the command line via echo "test message" | sendmail [email protected]. But anything I send from Monica just fails silently. Nothing shows up in the log or the .err file

Are you getting any errors in Monica's log files? They should be located in /path/to/monica/storage/logs if I recall correctly.

Nope. Nothing. Its as if Laravel sends the reminder to the Queue, then just forgets about it. I'm currently investigating this line of thought right now.

For future readers, my issue was not an email problem (birthday notifications work), it is a reminders problem (still don't work). So if you are debugging, consider this as an option.

Reminders are linked to the "paid" feature and if they are not sent, it might be linked to that. Are you sure you've set the REQUIRES_SUBSCRIPTION env variable to false?

(just to be clear: hosted your own instance is completely free and doesn't come with limitations UNLESS you indicate this variable to be true)

My reminders are working currently. I just got a reminder today in my inbox. So I don't believe it is tied in that way.

I'm seeing similar behavior. Things I've tried:

  • gmail SMTP using TLS
  • gmail SMTP using SSL
  • sendmail using SMTP on localhost (confirmed to work outside of Monica)
  • sendmail using /usr/sbin/sendmail (confirmed to work outside of Monica)
  • MAIL_DRIVER=log

None of the above seems to work for either notifications or reminders. Notifications at least process when the artisan job is run (as they are removed in the UI) but don't send mail. I did verify that .env is being read correctly as I can enable/disable new signups and it takes effect as expected, so I don't think that's the issue.

Nothing ever appears in storage/logs or in the sendmail log (when using sendmail).

If there's a way to enable more verbose logging on this path I'm happy to do that and troubleshoot or provide more info!

Do you have your cronjob set up properly?

@samjaninf if that was to me, then yes -- I can see that the cron job is running every minute.

But this shouldn't be affected by the cron job as I have run the same job by hand and observed that the notifications are being removed from the table (i.e. they are being processed) but nothing is being sent or logged (even when log output is set as the mail provider).

I've done some more digging on this and managed to get some reminders sent out. You must have the time to send reminders in your preferences set to the current hour if you are testing this, which is somewhat unexpected.

What I'd expect:
Running php artisan send:reminders would send all scheduled reminders if this is the right time to send them, or leave them queued if not.

What I observe:
Running php artisan send:reminders does not send any reminders if the current hour does not match the hour set for notifications in the user preferences, but still deletes the reminder entry!

Thus it appeared that everything except mail was working when I was running tests, but what was actually happening was that the notification was being silently deleted without ever attempting to send a message.

Not sure if that behavior is as expected or a bug but it was definitely confusing to me! :) It also means that it is never safe to run php artisan send:reminders in production as it will delete users' reminders for the current day unless it is the time they would receive those reminders anyway.

I'm also experiencing this issue. My instance is installed on a linux host following the Generic instructions. I've tried setting APP_DEBUG=true and MAIL_DRIVER=log and I can't get any new messages in my .../storage/logs folder. I've tested the login credentials and security type in another email program and they work, but I don't think that should matter since I don't see anything showing up in the logs.

Any ideas? I'm happy to help debug this further, but I'm not experienced at all with php/laravel so I don't know where to begin with this.

What I'd like to do is run a command like php artisan send:test_notification 1234 where 1234 is my user id or something. That would let me narrow it down to an email config/sending issue as opposed to a Reminder/Notification/Queue issue.

I had the same problem with my mail server. Found the answer here:
laravel-expected-response-code-250-but-got-code-530

Had to set MAIL_ENCRYPTION=tls when using port 587 with STARTTLS.

Nothing so far seems to be working. I am also using the Docker instance and GMail. The birthday emails seem to work (next up is tomorrow so I'll keep you posted) but I'm pretty tired of stumbling around in the dark.

If somebody has some hints I am open to them!

Same problem here with reminder emails.
I'm running Monica 2.16.0 on a raspberry pi 4b with Ubuntu server 18.04.

Created a running server like mentioned in the generic instructions.
Everything works fine except the reminder e-mail.

I can create users, change password, invite users and I DO receive a e-mail.
But the reminders aren't send. Any suggestions?

with the use of this post "Reminders not working #3324" I made it work for myself.

Something to do with the cron job.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

badry-abderrahmane picture badry-abderrahmane  路  3Comments

mattdavenport picture mattdavenport  路  3Comments

bensbox picture bensbox  路  3Comments

PM232 picture PM232  路  3Comments

asbiin picture asbiin  路  4Comments