• If you are still using CentOS 7.9, it's time to convert to Alma 8 with the free centos2alma tool by Plesk or Plesk Migrator. Please let us know your experiences or concerns in this thread:
    CentOS2Alma discussion

Resolved Mail handlers: Accessing "Received" header

Lutuh

New Pleskian
Hi all,

this question is about the Mail Handlers feature in Plesk 12.5 for Linux (https://docs.plesk.com/en-US/12.5/extensions-guide/mail-handlers.71844/). I'm using Postfix.

For an incoming email, I would like to get the sender IP address that can be found in the "Received" header, e.g.

Received: from somedomain.com (ec2-53-129-25-139.compute-1.amazonaws.com [53.129.25.139])
by ismtpd0002p1iad1.sendgrid.net (SG) with ESMTP id fO-7wrjmSeqrZAzFoOXgbg
for <[email protected]>; Mon, 24 Oct 2016 07:05:22.959 +0000 (UTC)

I've added a before-queue mail handler to Plesk and when looking at the email message that this handler receives via stdin, this header is missing. The message looks like this:

Subject: Test
Message-Id: <[email protected]>
Mon, 24 Oct 2016 07:05:22.959 +0000 (UTC)
From: [email protected]

<Message here>

My guess is that since this mail handler is pre-queue, there won't be any "Received" header until the message is being queued. So I went and registered a before-local handler, but this one does not even get called, so no "Received" header there, either.

Thank you for any ideas or suggestions you might have on this topic. I know it has to work somehow because the onboard "SPF" mail handler has to be able to access the sender IP as well in order to function at all.

Cheers,
Lucas
 
Got it figured out. I was initially using the same mailbox for sending that test email, so using local delivery. It looks like the "Received" header won't show up then. When using a different, non-local mailbox to send the test email, the "Received" header shows up just fine. May this be of use for someone.
 
If using the before-queue type mail handler, the sender IP and HELO hostname can be found in the environment variables SMTPHELOHOST and TCPREMOTEIP.
 
Hello @Lutuh,
I am trying to create a mail handler that sends certain emails to an external server, but I can't get the bcc header, did you know anything that could help me? How can I access this environment variables that you talk about?
 
Back
Top