Discussion:
[Mimedefang] Get recipients
Stagiair 2. Cisa
2017-03-20 15:52:33 UTC
Permalink
Hi,

I made a replace attachment function with MIMEDefang and it works like a charm.
Now I want to integrate the possibility to toggle that function.

I work with a database where a Boolean decides the attachment should be replaced or not, depending on what email address I send to the function.
And I made it work.

Now coming to the point: I always had a fixed value for the email adress to test my functions but now I want to get the email address(es) from the incoming mails.
I searched Google for hours and tried several things to get the recipient's email address but I can't find it anywhere.

Sorry if it's very obvious and I'm completely missing the point but I'm kinda out of options at the moment.

Hope you guys can help me.

Kind regards,
Jente


------------------------------------------------------------------
This message has been scanned for viruses and dangerous content by
Cisa Antispam Service, and is believed to be clean.
------------------------------------------------------------------
Richard Laager
2017-03-20 20:18:11 UTC
Permalink
Post by Stagiair 2. Cisa
Now coming to the point: I always had a fixed value for the email adress
to test my functions but now I want to get the email address(es) from
the incoming mails.
Look at the @Recipients array.

Obviously, a single message may have multiple recipients, so you need to
deal with that accordingly. For example, if you have one recipient who
wants the attachment replaced and one who does not, what do you do? The
details of how you want to handle that depend on the situation. If you
want to honor both, you will need to do something involving resending
the message--see resend_message(). See also stream_by_recipient().

See `man mimedefang-filter` for more details.
--
Richard
_______________________________________________
NOTE: If there is a disclaimer or other legal boilerplate in the above
message, it is NULL AND VOID. You may ignore it.

Visit http://www.mimedefang.org and http://www.roaringpenguin.com
MIMEDefang mailing list ***@lists.roaringpenguin.com
http://lists.roaringpenguin.com/mailman/listinfo/mime
Richard Laager
2017-04-07 16:21:11 UTC
Permalink
Should I call it on a specific time or in a specific function?
It is available at filter_begin() through filter_end() time, with all of
the recipients. From `man mimedefang-filter`, "In filter_recipient, it
is set to the single recipient currently under consideration."
--
Richard
_______________________________________________
NOTE: If there is a disclaimer or other legal boilerplate in the above
message, it is NULL AND VOID. You may ignore it.

Visit http://www.mimedefang.org and http://www.roaringpenguin.com
MIMEDefang mailing list ***@lists.roaringpenguin.com
http://lists.roaringpenguin.com/mailman/listinfo/mimedefang
Richard Laager
2017-04-11 19:43:48 UTC
Permalink
I've checked on capitals and this was fine. It looked like a non-existing or empty array.
After some testing I've found out the array actually really exists and I can access it.
The only problem is that the values (the different recipients addresses) are empty in the array.
When I send to 3 recipients, it actually sees that there are 3 recipients but instead of giving me the addresses it returns an empty string.
So I think the array is like
@Recipients = ("", "", "");
Same for 2 recipients, it sees there are 2 but returns empty strings.
@Recipients = ("", "");
I tried using foreach to get the recipients out of the array.
I've also tried using #Recipients[i], but no success either.
Please keep your replies on-list, not just to me individually.

I don't know why you'd be seeing that. I use @Recipients extensively in
my filter and it works fine.

I'd probably try sticking some syslog calls in mimedefang.pl (the actual
mimedefang code) where it sets @Recipients. Then trace from there.
--
Richard
_______________________________________________
NOTE: If there is a disclaimer or other legal boilerplate in the above
message, it is NULL AND VOID. You may ignore it.

Visit http://www.mimedefang.org and http://www.roaringpenguin.com
MIMEDefang mailing list ***@lists.roaringpenguin.com
http://lists.roaringpenguin.com/mailm
Stagiair 2. Cisa
2017-04-12 09:12:10 UTC
Permalink
Hey Richard

I'm working directly into the mimedefang.pl now.

Same problem as before, the size of the array is right but it has empty values.

Could this be the result of using an EFA-server? (https://efa-project.org/about/)
It uses postfix instead of sendmail.

Or do you have any other ideas why it's not filling up?

Kind regards

Jente Busschodts


-----Original Message-----
From: Richard Laager [mailto:***@wiktel.com]
Sent: dinsdag 11 april 2017 21:44
To: Stagiair 2. Cisa <***@cisanet.be>
Cc: ***@lists.roaringpenguin.com
Subject: Re: [Mimedefang] Get recipients
I've checked on capitals and this was fine. It looked like a non-existing or empty array.
After some testing I've found out the array actually really exists and I can access it.
The only problem is that the values (the different recipients addresses) are empty in the array.
When I send to 3 recipients, it actually sees that there are 3 recipients but instead of giving me the addresses it returns an empty string.
So I think the array is like
@Recipients = ("", "", "");
Same for 2 recipients, it sees there are 2 but returns empty strings.
@Recipients = ("", "");
I tried using foreach to get the recipients out of the array.
I've also tried using #Recipients[i], but no success either.
Please keep your replies on-list, not just to me individually.

I don't know why you'd be seeing that. I use @Recipients extensively in my filter and it works fine.

I'd probably try sticking some syslog calls in mimedefang.pl (the actual mimedefang code) where it sets @Recipients. Then trace from there.

--
Richard

_______________________________________________
NOTE: If there is a disclaimer or other legal boilerplate in the above
message, it is NULL AND VOID. You may ignore it.

Visit http://www.mimedefang.org and http://www.roaringpenguin.com
MIMEDefang mailing list ***@lists.roaringpenguin.com
http://lists.
Richard Laager
2017-04-12 17:54:59 UTC
Permalink
Post by Stagiair 2. Cisa
Could this be the result of using an EFA-server? (https://efa-project.org/about/)
It uses postfix instead of sendmail.
I use postfix.

The first argument to filter_recipient() is the recipient. The same
value is also put into the first element of @Recipients.

Add these three lines, exactly, to filter_recipient():

sub filter_recipient()
{
my $a = $_[0];
my $b = $Recipients[0];
md_syslog('info', "a = $a ; b = $b");
}

See what that outputs. My output looks like this:
a = <***@wiktel.com> ; b = <***@wiktel.com>

If you get something like that, then whatever code you wrote to look at
@Recipients is wrong. Start with the working code and you should be able
to figure it out.

If that exact code outputs:
a = ; b =
then the recipient value really is the empty string, and I have no idea why.
--
Richard
_______________________________________________
NOTE: If there is a disclaimer or other legal boilerplate in the above
message, it is NULL AND VOID. You may ignore it.

Visit http://www.mimedefang.org and http://www.roaringpenguin.com
MIMEDefang mailing list ***@lists.roaringpenguin.com
http://lists.roa
Stagiair 2. Cisa
2017-04-13 08:38:16 UTC
Permalink
Hey Richard

I'm using your code but md_syslog doesn't seem to output anything to my logfiles.

Im using rsyslog and my logs should be in /var/log/messages.
But I see nothing from the md_syslog coming up.

Kind regards
Jente


-----Original Message-----
From: Richard Laager [mailto:***@wiktel.com]
Sent: woensdag 12 april 2017 19:55
To: Stagiair 2. Cisa <***@cisanet.be>
Cc: ***@lists.roaringpenguin.com
Subject: Re: [Mimedefang] Get recipients
Post by Stagiair 2. Cisa
Could this be the result of using an EFA-server?
(https://efa-project.org/about/) It uses postfix instead of sendmail.
I use postfix.

The first argument to filter_recipient() is the recipient. The same value is also put into the first element of @Recipients.

Add these three lines, exactly, to filter_recipient():

sub filter_recipient()
{
my $a = $_[0];
my $b = $Recipients[0];
md_syslog('info', "a = $a ; b = $b"); }

See what that outputs. My output looks like this:
a = <***@wiktel.com> ; b = <***@wiktel.com>

If you get something like that, then whatever code you wrote to look at @Recipients is wrong. Start with the working code and you should be able to figure it out.

If that exact code outputs:
a = ; b =
then the recipient value really is the empty string, and I have no idea why.

--
Richard

_______________________________________________
NOTE: If there is a disclaimer or other legal boilerplate in the above
message, it is NULL AND VOID. You may ignore it.

Visit http://www.mimedefang.org and http://www.roaringpenguin.com
MIMEDefang mailing list ***@lists.roaringpenguin.com
http://l

Kevin A. McGrail
2017-04-12 17:56:38 UTC
Permalink
Post by Stagiair 2. Cisa
I'm working directly into the mimedefang.pl now.
Same problem as before, the size of the array is right but it has empty values.
Could this be the result of using an EFA-server? (https://efa-project.org/about/)
It uses postfix instead of sendmail.
Or do you have any other ideas why it's not filling up?
Hi Staigiair,

I use MD with both postfix and sendmail and use @Recipients without
concern. You have something fundamentally wrong as this is really a
basic issue.

@Recipients might not be set in filter_recipient. And if you are using
add_recipient, it doesn't change. I don't think there are many other
restrictions.

So if the array length is changing but the array values are not, I can
only extrapolate that there is something very odd.

Best if you post a filter for us to look at.

Or if you know you have logging working, in filter_begin add this:

my ($output);

foreach my $recip (@Recipients) {

$output .= " $recip ";

}

md_syslog('info',$output);


And test what you see in your logs.

Untested while grabbing lunch, but that basic code must work or you are
fundamentally building on a flawed foundation.


Regards,
KAM

_______________________________________________
NOTE: If there is a disclaimer or other legal boilerplate in the above
message, it is NULL AND VOID. You may ignore it.

Visit http://www.mimedefang.org and http://www.roaringpenguin.com
MIMEDefang mailing list ***@lists.roaringpenguin.com
http://lists.roaringpenguin.com
Loading...