• Please be aware: Kaspersky Anti-Virus has been deprecated
    With the upgrade to Plesk Obsidian 18.0.64, "Kaspersky Anti-Virus for Servers" will be automatically removed from the servers it is installed on. We recommend that you migrate to Sophos Anti-Virus for Servers.
  • The Horde webmail has been deprecated. Its complete removal is scheduled for April 2025. For details and recommended actions, see the Feature and Deprecation Plan.
  • We’re working on enhancing the Monitoring feature in Plesk, and we could really use your expertise! If you’re open to sharing your experiences with server and website monitoring or providing feedback, we’d love to have a one-hour online meeting with you.

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