Gmail - Delivery Status Notification (Delay/Failed)


#1

Hey all,

Out of nowhere, I’m getting these emails from Google emails of failed attempts to deliver email. I’m using Gmail’s SMTP server for voicemail and module updates notifications.
My Gmail is getting filled with these:

    Delivery incomplete
There was a temporary problem delivering your message to asterisk@myfreepbxhostname.mydomain.net. Gmail will retry for 22 more hours. You'll be notified if the delivery fails permanently.
LEARN MORE
The response was:
The recipient server did not accept our requests to connect. Learn more at https://support.google.com/mail/answer/7720 [freepbx.marinko.net 76.xxx.xxx.xxx: timed out]




---------- Forwarded message ----------
From: "(Cron Daemon)" <johnnyxxxxxx@gmail.com>
To: asterisk@myfreepbxhostname.mydomain.net
Cc: 
Bcc: 
Date: Mon, 19 Jul 2021 06:00:01 -0700 (PDT)
Subject: Cron <asterisk@freepbx> /var/www/html/admin/modules/sangomaconnect/bin/keep_alive.php 2>&1 >/dev/null
/bin/sh: /var/www/html/admin/modules/sangomaconnect/bin/keep_alive.php: No such file or directory

(Matt Brooks) #2

I’m not sure that asterisk@myfreepbxhostname.mydomain.net is a valid email. I’m guessing your question has to do with how do you fix the email recipient of cron emails?


(David55) #3

I don’t know how FreePBX handles an external mail server, but this would happen if provides a sendmail program that simply forwards everything to the external server, without attempting to do local delivery of local addresses.

Generally linux programs that want to send mail, other than the big mail clients, like thunderbird, hand off the mail to “sendmail”. Even if the mail server isn’t actually the sendmail package, it will still implement a program of that name.

There is a second issue here, which isn’t about implementation details. The mail that got bounced was produced because a cron job failed. Successful jobs would normally be silent. Consequently, one wants to consider the contents of the bounced message as a symptom of a problem that isn’t related to email.


(Matt Brooks) #4

@david55 You’re correct. It sounds like there are two issues going on:

  1. The email recipient is misconfigured on the cron email
  2. The keep_alive.php script is missing from the sangomaconnect module.

#5

Thank you all for the replies!

asterisk@myfreepbxhostname.mydomain.net is obviously masked for privacy, but my domain does not have mail configured.

I’ve removed sangomaconnect module, but emails are still being sent, some delayed, and some failed. I guess that Gmail will keep trying for quite some time before it marks it as failed.

Does anyone know where asterisk@myfreepbxhostname.mydomain.net is stored? If I replaced it with my valid johnnyxxxxxx@gmail.com this would stop.


(David55) #6

The asterisk part is almost certainly obtained by translating the owner for the relevant cron file to it symbolic way, in the normal Unix/Linux way (i.e. using /etc/passwd). The domain name is probably taken from /etc/hosts. It will be trying to email the owner of the file, assuming that email handling has been correctly configured for that.


(David55) #7

This is an extract from “man 5 crontab”, for Debian, but other Linuxes are likely to be similar. I’m assuming you are getting the default behaviour:

In addition to LOGNAME, HOME, and SHELL, cron(8) will look at MAILTO if
it has any reason to send mail as a result of running commands in
``this’’ crontab. If MAILTO is defined (and non-empty), mail is sent
to the user so named. MAILTO may also be used to direct mail to multi‐
ple recipients by separating recipient users with a comma. If MAILTO
is defined but empty (MAILTO=""), no mail will be sent. Otherwise mail
is sent to the owner of the crontab.

Please read the full man page for the full context of this quote.


#8

I’ve tried to find where to set MAILTO, but with no luck. My email setup Debug on System Admin module is full of bounced emails and the same message repeats every 5 minutes. My IP is banned.
Does anyone know where asterisk@myfreepbxhostname.mydomain.net is stored?
After the latest module update it looks like sangomaconnect module is again on my system:

[root@freepbx ~]# crontab -u asterisk -l

*/15 * * * * [ -e /etc/asterisk/firewall.enabled ] && touch /var/spool/asterisk/                                                                                                                                                             incron/firewall.firewall
*/5 * * * * /usr/sbin/fwconsole firewall sync > /dev/null 2>&1
@daily /usr/sbin/fwconsole pms mk_dirty > /dev/null 2>&1
0 1 * * * /var/www/html/admin/modules/iotserver/bin/check_license.php 2>&1 >/dev                                                                                                                                                             /null
0 2 * * * /var/www/html/admin/modules/iotserver/bin/check_certificates.php 2>&1                                                                                                                                                              >/dev/null
0 4 * * * /var/www/html/admin/modules/iotserver/bin/refresh_tzoffsets.php 2>&1 >                                                                                                                                                             /dev/null
*/1 * * * * /var/www/html/admin/modules/iotserver/bin/check_system_settings.php                                                                                                                                                              2>&1 >/dev/null
33 0 * * * /usr/sbin/fwconsole certificates --updateall -q 2>&1 >/dev/null
* * * * * /usr/sbin/fwconsole queuestats --syncall >> /tmp/reader.log 2>&1
@daily [ -x /var/lib/asterisk/bin/freepbx_sipstation_check ] && /var/lib/asteris                                                                                                                                                             k/bin/freepbx_sipstation_check 2>&1 > /dev/null
*/5 * * * * /var/www/html/admin/modules/sangomaconnect/bin/keep_alive.php 2>&1 >                                                                                                                                                             /dev/null
0 2 * * * /var/www/html/admin/modules/sangomaconnect/bin/check_certificates_sc.p                                                                                                                                                             hp 2>&1 >/dev/null
0 1 * * * /var/www/html/admin/modules/sangomaconnect/bin/check_license_sc.php
* 3 * * * /usr/sbin/fwconsole util cleanplaybackcache -q
55 5 * * 6 [ -e /usr/sbin/fwconsole ] && /usr/sbin/fwconsole ma listonline --sen                                                                                                                                                             demail -q > /dev/null 2>&1
* * * * * [ -e /usr/sbin/fwconsole ] && sleep $((RANDOM\%30)) && /usr/sbin/fwcon                                                                                                                                                             sole job --run --quiet 2>&1 > /dev/null
[root@freepbx ~]#

Debug log

Jul 27 15:00:03 freepbx postfix/qmgr[20332]: 669093019A0A1: removed
Jul 27 15:05:01 freepbx postfix/pickup[6575]: 7E7183019A0A0: uid=995 from=<asterisk>
Jul 27 15:05:01 freepbx postfix/cleanup[14757]: 7E7183019A0A0: message-id=<20210727220501.7E7183019A0A0@freepbx>
Jul 27 15:05:01 freepbx postfix/qmgr[20332]: 7E7183019A0A0: from=<asterisk@myfreepbxhostname.mydomain.net>, size=868, nrcpt=1 (queue active)
Jul 27 15:05:02 freepbx postfix/smtp[14764]: 7E7183019A0A0: to=<asterisk@myfreepbxhostname.mydomain.net>, orig_to=<asterisk>, relay=smtp.gmail.com[74.125.195.109]:587, delay=1, delays=0.05/0.04/0.85/0.11, dsn=5.4.5, status=bounced (host smtp.gmail.com[74.125.195.109] said: 550 5.4.5 Daily user sending quota exceeded. d67sm4928916pfd.81 - gsmtp (in reply to DATA command))
Jul 27 15:05:02 freepbx postfix/cleanup[14757]: 8A5073019A0A1: message-id=<20210727220502.8A5073019A0A1@freepbx>
Jul 27 15:05:02 freepbx postfix/qmgr[20332]: 8A5073019A0A1: from=<>, size=2858, nrcpt=1 (queue active)
Jul 27 15:05:02 freepbx postfix/bounce[14793]: 7E7183019A0A0: sender non-delivery notification: 8A5073019A0A1
Jul 27 15:05:02 freepbx postfix/qmgr[20332]: 7E7183019A0A0: removed
Jul 27 15:05:03 freepbx postfix/smtp[14764]: 8A5073019A0A1: to=<asterisk@myfreepbxhostname.mydomain.net>, relay=smtp.gmail.com[74.125.195.109]:587, delay=1.3, delays=0/0/0.76/0.56, dsn=5.4.5, status=bounced (host smtp.gmail.com[74.125.195.109] said: 550 5.4.5 Daily user sending quota exceeded. z124sm5252256pgb.6 - gsmtp (in reply to DATA command))
Jul 27 15:05:03 freepbx postfix/qmgr[20332]: 8A5073019A0A1: removed

(David55) #9

Assuming that you have the cron daemon that matches the man page I used, you put it at the start of the file you displayed in your last post. You would need to use the -e, rather than the -l, option.

I can’t guarantee that it will expect a full internet email address, as this sort of thing pre-dated internet email and, historically, would have used local email, on the machine.

MAILTO=user@domain

*/15 * * * * [ -e /etc/asterisk/firewall.enabled ] && touch /var/spool/asterisk/                                                                                                                                                             incron/firewall.firewall
*/5 * * * * /usr/sbin/fwconsole firewall sync > /dev/null 2>&1
@daily /usr/sbin/fwconsole pms mk_dirty > /dev/null 2>&1
0 1 * * * /var/www/html/admin/modules/iotserver/bin/check_license.php 2>&1 >/dev                                                                                                                                                             /null
0 2 * * * /var/www/html/admin/modules/iotserver/bin/check_certificates.php 2>&1                                                                                                                                                              >/dev/null
0 4 * * * /var/www/html/admin/modules/iotserver/bin/refresh_tzoffsets.php 2>&1 >                                                                                                                                                             /dev/null
*/1 * * * * /var/www/html/admin/modules/iotserver/bin/check_system_settings.php                                                                                                                                                              2>&1 >/dev/null
33 0 * * * /usr/sbin/fwconsole certificates --updateall -q 2>&1 >/dev/null
* * * * * /usr/sbin/fwconsole queuestats --syncall >> /tmp/reader.log 2>&1
@daily [ -x /var/lib/asterisk/bin/freepbx_sipstation_check ] && /var/lib/asteris                                                                                                                                                             k/bin/freepbx_sipstation_check 2>&1 > /dev/null
*/5 * * * * /var/www/html/admin/modules/sangomaconnect/bin/keep_alive.php 2>&1 >                                                                                                                                                             /dev/null
0 2 * * * /var/www/html/admin/modules/sangomaconnect/bin/check_certificates_sc.p                                                                                                                                                             hp 2>&1 >/dev/null
0 1 * * * /var/www/html/admin/modules/sangomaconnect/bin/check_license_sc.php
* 3 * * * /usr/sbin/fwconsole util cleanplaybackcache -q
55 5 * * 6 [ -e /usr/sbin/fwconsole ] && /usr/sbin/fwconsole ma listonline --sen                                                                                                                                                             demail -q > /dev/null 2>&1
* * * * * [ -e /usr/sbin/fwconsole ] && sleep $((RANDOM\%30)) && /usr/sbin/fwcon                                                                                                                                                             sole job --run --quiet 2>&1 > /dev/null

I’m not familiar with postfix, or how FreePBX configures it when you set it up to use gmail, but as this is going through postfix, there is almost certainly a way of defining mail aliases so that asterisk at the local machine gets translated into a usable internet email address.


(David55) #10

I’d suggest looking into this:

http://www.postfix.org/aliases.5.html

although, as I say, I haven’t used it myself.


(David55) #11

I quick scan of the results of googling “freepbx mail aliases” suggests there may be some useful information there.


(Andrew) #12

You should be using postfix. That way you can set the generic file and create as many aliases as you want.


#13

Thank you guys!
I think I solved it by adding MAILTO= johnnyxxxxxx@gmail.com at the top of crontab file. This is the latest email I got:
Subject:
Cron asterisk@freepbx /var/www/html/admin/modules/sangomaconnect/bin/check_license_sc.php
From:
(Cron Daemon) johnnyxxxxxx@gmail.com
To: johnnyxxxxxx@gmail.com
Body:
SangomaConnect Server is not running

Not sure how to start it?

I just don’t understand that I’m the only one who uses Gmail as an email provider.

Here’s the video how edit crontab with vi


(Jared Busch) #14

You were told the right way to fix things. That is to use normal postfix settings instead of a bludgeon in the cron file.

There are even examples here on the community.


(Jared Busch) #15

If you are not using it, it should be removed.

fwconsole ma delete sangomaconnect

#16

@sorvani thanks for the tip!

Ok, I removed sangomaconnect.
If I remove MAILTO= mailto:johnnyxxxxxx@gmail.com from my crontab file
Where would I put johnnyxxxxxx@gmail.com ? Whereever there’s pbx@domain.com reference?
And, what about last line @pbx.domain.com @domain.com ?