Troubleshooting email notifications

General checks to perform when emails are not sent

Send a test mail 

Script the following sql command in order to check if your system is correctly configured to send out email.
Please replace party_from /party_to (624) with an existing, suitable user_id.

select acs_mail_nt__post_request (
624,                 	-- party_from
624,  			-- party_to
'f',                    -- expand_group
'Test Subject',         -- subject
'Test Body',            -- message
0                       -- max_retries
);

Alternatively you can use the ]po[ Developer Shell and execute the following function:

acs_mail_lite::send \
        -send_immediately \
        -to_addr recipient@test.com \
        -from_addr sender@test.com \
        -subject "Test Subject" \
        -body "Test Body"

When 'send_immediately' is not set, the mail should remain in table 'acs_mail_queue_outgoing' until a Mail Sweeper passes it on to a local MTA or a SMTP server. 

projop=# select * from acs_mail_queue_outgoing;
 message_id |          envelope_from          |           envelope_to
------------+---------------------------------+---------------------------------
     562538 | ben.bigboss@project-open.com    | ben.bigboss@project-open.com
(1 row)


If an email remains in the table for a long time without being sent, check your mail log for error messages.
On most Linux systems the log file can be found at /var/log/maillog

Make sure your system runs the latest version of packages 'acs-mail-lite'

]po[ V4.x saw some changes to file /packages/acs-mail-lite/tcl/acs-mail-lite-procs.tcl and /packages/acs-mail/tcl/acs-mail-procs.tcl
Make sure you are using the most recent version. 

Check mail scheduler

Its rather unlikely that email is not being send due to issues with the schedulers. However, find below additional information.
For sending emails ]po[ is using services provided by two separate packages:

  • acs-mail-lite provides function acs_mail_lite::load_mails that is scheduled in /web/projop/packages/acs-mail-lite/tcl/acs-mail-lite-init.tcl
    Please check if your log file /web/projop/log/error.log show entries such as 'Debug: Running scheduled proc acs_mail_lite::load_mails...'

  • acs-mail provides function acs_mail_process_queue that is scheduled in /web/projop/packages/acs-mail/tcl/acs-mail-init.tcl
    Please check if your log file /web/projop/log/error.log show entries such as 'Notice: acs_mail_process_queue: entering ...'

Issues when using a local MTA

Linux: Make sure that your MTA is up and running and accepts and sends email

Linux based ]po[ distributions you'll find quite likely 'postfix' installed. To check if postfix is running, open a shell and execute:

ps waux | grep postfix

You should see among other output the following line (path might differ):

/usr/libexec/postfix/master

Check the status of the postfix server by either running

/etc/init.d/postfix status

or

systemctl status postfix.service

...which should return something like:

master (pid  1469) is running...

or:

...
Aug 29 07:29:55 project-open-v50 systemd[1]: Starting Postfix Mail Transport Agent...
Aug 29 07:31:15 project-open-v50 postfix/postfix-script[1540]: starting the Postfix mail system
Aug 29 07:31:16 project-open-v50 postfix/master[1543]: daemon started -- version 2.10.1, configuration /etc/postfix
Aug 29 07:31:16 project-open-v50 systemd[1]: Started Postfix Mail Transport Agent.

Check system mail queue

Run

         mailq -v

If there are still mail messages pending, this command should show you why. For example, you might see something like "Deferred: Connection refused by <some SMTP server>"
[Tx to Terrance Crow]

Check your postfix configuration

Bounces due to an invalid sender domain:
Feb 21 14:03:11 localhost postfix/smtp[4669]: 9F8F3B80B1: host mx01.schlund.de[212.227.15.186] said: 421 invalid sender domain 'project-open-v34.localdomain' (misconfigured dns?) (in reply to RCPT TO command)
are fixed by setting the following parameters in your /etc/postfix/main.cf:
myhostname = your-company.com
mydomain = your-company.com

Check log file

Have a look at the log file (default location on most linux systems: /var/log/maillog)  

Check local DNS server for MX Record

In case mail is only send out to "external" recipients, but not to local recipients, check the MX record of your local DNS server.

Check your resolv.conf

Check your DNS server entries in /etc/resolv.conf.  Please check that the DNS servers are working. Be aware that mydns is not able to resolve external domains, so you will have to enter a DNS server that is capable of resolving external domains too.

[ref]

Check if your ISP requires valid bounce addresses

Some ISP (and everyday more) do exhaustive validation checks before accepting email. In some case providers check for a valid bounce address.
In OpenACS package acs-mail-lite builds random system email addresses to manage bounces instead of real addresses. Validation checks performed by ISP's would fail returning the following error message;

Feb 14 10:25:30 localhost postfix/local[14071]: CD99CB8078: to=, relay=local, delay=0.48, delays=0.34/0.08/0/0.06, dsn=5.1.1, status=bounced (unknown user: "bounce-31300-a61ed9ca5c39b63ddf28c3862041d042bd73450a-21457")

or

550-Requested action not taken: mailbox unavailable 550 invalid DNS A/AAAA resource record (in reply to MAIL FROM command)

The easiest way to fix this, is patching /packages/acs-mail-lite/tcl/bounce-procs.tcl be so that "bounce_address" it simply return a valid email address.

    #---------------------------------------
    ad_proc -public bounce_address {
        -user_id:required
        -package_id:required
        -message_id:required
    } {
        Composes a bounce address
        @option user_id user_id of the mail recipient
        @option package_id package_id of the mail sending package
        (needed to call package-specific code to deal with bounces)
        @option message_id message-id of the mail
        @return bounce address
    } {
        return "info@your-company.com"
        # return "[bounce_prefix]-$user_id-[ns_sha1 $message_id]-$package_id@[address_domain]"
    }


(Thanks to Frank Diekhoff, Pentamino GmbH for pointing this out)

Only mails to local domains fail to be delivered 

/var/log/maillog contains 550 error:

NOQUEUE: reject: RCPT from localhost.localdomain[127.0.0.1]: 550 5.1.1 xx@my-domain.com: Recipient address rejected: User unknown in local recipient table; from=info@my-domain.com to=xx> proto=ESMTP helo=localhost /localhost/xxinfo@my-domain.com xx@my-domain.com

To turn off unknown local recipient rejects by the SMTP server, consider specifying in /etc/postfix/main.cf:

local_recipient_maps =

This setting is not recommended if your ]po[ server accepts incoming emails. For additional information pls. refer to the postfix documentation

Issues when using a SMTP server

If sending fails, there's a chance that the system does not write any error messages to the log files. To visualize the feedback received from the SMTP server, please open a ]po[ Developer Shell and execute the code below. Set values for SMTP server, recipient, etc. accordingly:

set text {some text with 8 special characters äöü ÄÖÜ ß €}
set tok [mime::initialize -canonical text/plain -param {charset "utf-8"} -encoding 8bit -string [encoding convertto utf-8 $text]]
set erg [smtp::sendmessage $tok \
    -servers my.smtp-server.com \
    -recipients recipient@test.com \
    -usetls 1 \
    -username mail_user_1 \
    -password 123456 \
    -header [
        list Subject [mime::word_encode utf-8 quoted-printable $text]] \
    -header [list From me@test.com] \
    -header [list To recipient@test.com]
]
The following error is an indicator that your SMTP service provider requires tls mail encryption:
 An error such as:

Server responses

  • 554: Sender address rejected: please provide address (in reply to RCPT TO command) / 504 : Sender address rejected: need fully-qualified address (in reply to RCPT TO command))
    These errors might be caused by a missing ]project-open[ parameter 'BounceDomain' in package 'acs-mail-lite'.

  • ERROR:error reading "sock9": connection refused
    your SMTP service provider requires tls mail encryption

  • {recipient@test.com 454 {4.7.1 : Relay access denied}}
    Sender authentication failed.

Other

Using sendmail on Ubuntu

Please see:

References:



  Contact Us
  Project Open Business Solutions S.L.

Calle Aprestadora 19, 12o-2a

08902 Hospitalet de Llobregat (Barcelona)

Spain

 Tel Europe: +34 609 953 751
 Tel US: +1 415 200 2465
 Mail: info@project-open.com