UksusoFF/webtrees-reminder

Not recieving email

Closed this issue · 16 comments

Hello,
I like the idea of this plugin but it is not working for me. I am on Webtrees 2.0.7.
I have installed your plugin as instructed, and changed the folder and its contents to the www-data user.
I have set the cron job to run under the www-data user as well.
I have also tried to run it manually, without the -q parameter, and it says {"success":true} but I never get an email... I have BIRT events today and I would expect it to work today. I have also setup a fake BIRT event on a person for tomorrow as testing.

I do get an email in other parts of Webtrees, and when I do the email test from the control panel. So I know email is working.

I was wondering if it might be because of this line of code?
I am going to dig deeper into what this does later, but I wanted to let you know it wasn't working.

root@servername:/var/www/webtrees/modules_v4/reminder# wget -O - "https://servername.ca/index.php?route=/reminder-cron/run&key=mykey"
--2020-08-11 20:39:05--  https://servername.ca/index.php?route=/reminder-cron/run&key=mykey
Resolving servername.ca (servername.ca)... 123.123.123.123
Connecting to servername.ca (servername.ca)|123.123.123.123|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 16 [application/json]
Saving to: ‘STDOUT’
-0%[  ]       0  --.-KB/s               {
-100%[  ]      16  --.-KB/s    in 0s
2020-08-11 20:39:07 (1.50 MB/s) - written to stdout [16/16]

Thank you for making this addon. I think it's an important one to have and I will work with you to get it working! 👍

Can you post screenshot of your /admin/email page?
Sender name must be filled and (for most SMTP servers) must be same as Username.

Hello,

2020-08-12 09_07_19-Window

Some things to consider:

  • my sending server name is different than my webtrees domain. My webtrees instance uses a subdomain so if that's an issue let me know.
  • I'm using TLS encryption.
  • My email server name is completely different than my sending server or webtrees server.

But again, these things work with Webtrees built in emails, just not this addon.

Can you open this url in browser and show screenshot?
https://servername.ca/index.php?route=/reminder-cron/run&key=yourkey
Module configuration page screen also needed (mask key on it).
Also please ensure that you have birthday of living people today.

Here are two screenshots.
One that shows I have a DOB today. One that shows the response from the URL.
And yes, I have the switch turned on in the configuration page so that my user should get the email.

2020-08-12 11_48_43-Window

2020-08-12 11_49_55-My page – webtrees

Your user is admin? User can see person which have birthday today? Rigth?

Yes. I am the admin and one of only two users for my setup. Thanks.

Please go to CronController and replace run method with this:



    private function run(Request $request): Response
    {
        $events = [];

        if ($request->getQueryParams()['key'] !== $this->module->getSettingCronKey()) {
            throw new HttpAccessDeniedException();
        }

        $this->users->all()->each(function(User $user) use (&$events) {
            $reminders = [];

            if (filter_var($user->getPreference(ReminderModule::SETTING_EMAIL_NAME, 'false'), FILTER_VALIDATE_BOOLEAN)) {
                $reminders[] = 'email';
            }

            if (empty($reminders)) {
                return;
            }

            Auth::login($user);
            I18N::init($user->getPreference(User::PREF_LANGUAGE, 'en'));

            $this->trees->all()->each(function(Tree $tree) use ($user, $reminders, &$events) {
                $facts = $this->events->getEventsList(
                    Carbon::now()->julianDay(),
                    Carbon::now()->julianDay(),
                    implode(',', [
                        'BIRT',
                        'MARR',
                    ]),
                    true,
                    'alpha',
                    $tree
                );

                if ((is_array($facts) && !empty($facts)) || $facts->isNotEmpty()) {
                    foreach ($facts as $fact) {
                        /** @var \Fisharebest\Webtrees\Fact $fact */
                        $events[$user->email()][] = $fact->label();
                    }
                    $this->sendFacts($tree, $user, collect($facts), $reminders);
                }
            });
            Auth::logout();
        });

        return response([
            'success' => true,
            'events' => $events,
        ]);
    }

Next go to cron url in browser and check response. Can you see birthday here?

It shows a 0?
As you saw in my previous message that included a screenshot, I definitely have a DOB today.
image

Zero is array key. One Birth item exists.
So email should be sent.
Please try to check webtrees logs. Any errors here?

You have user with email equals "Sender name" from mail config page?

You have user with email equals "Sender name" from mail config page?

No, none of my users use the sender name email. That is a noreply email address that I created and use for sending automated emails.

I also checked the apache error log for that site and nothing is showing up in it.

Try check "Send a test email using these settings" on /admin/email page. You got test message?

Yes, the send test works. Password recovery email works. So does mass email to users. Just this reminder addon doesn't work unfortunately.

This is very strange. Module use same EmailService with WT.
Will try add something logs to emailing.

Can you try latest master?

Your changes in the latest update have resolved the issue and I received a test email. Thank you so much for the resolution!