<div dir="ltr">Ok <div><br></div><div>This is my proof of concept code</div><div><br></div><div>Added to the sub reinject_mail:</div><div><br></div><div><br></div><div><div> # smtp 10025 = orginal pmg , INCOMING</div><div> # smtp 10026 = OUTGOING</div><div><br></div><div>        my %relay_domains = () ;</div><div>        my $inject_port = 10025 ;</div><div><br></div><div>        if ( -e "/etc/pmg/domains" ) {</div><div>                open DOMAINS,"</etc/pmg/domains" ;</div><div><br></div><div>                while ( <DOMAINS> ) {</div><div>                        my $domain = $_ ;</div><div>                        $domain =~ s/1//g;</div><div>                        $domain =~ s/\s+//g;</div><div>                        $relay_domains{$domain} = 1 ;</div><div>                        syslog ('info', "- Domain $domain loaded");</div><div>                }</div><div><br></div><div>                syslog ('info', '- Protected domains loaded completed.');</div><div><br></div><div>                close DOMAINS ;</div><div>        }</div></div><div><br></div><div><br></div><div><div> if ( defined $relay_domains{$domain_part} )  {</div><div>                $inject_port = "10026" ;</div><div>                syslog('info', "Domin $domain_part is Local: Outgoing port: $inject_port");</div><div><br></div><div>        } else {</div><div>                syslog('info', "Domin $domain_part is Local: Incoming port: $inject_port");</div><div><br></div><div>        }</div><div><br></div><div><br></div><div>        my $smtp = Net::SMTP->new('127.0.0.1', Port => $inject_port, Hello => $me) ||</div><div>            die "unable to connect to localhost at port 10025"</div></div><div><br></div><div><br></div><div>The concept is to load the relay_domains in hash AND to change the $inject_port based on the fact that the sender's domain is found in the hash.</div><div>If the domain is found I assume that is a OUTGOING mail and so change the port to 10026 </div><div><br></div><div>The problem of this code is that at EVERY call of reinject_mail I need to reload all the domains ad thus read the file on the file system.</div><div>I have tried to load the hash directly from the pmg-smtp-filter code BUT the sub reinject_mail does not "see" it.</div><div><br></div><div>Maybe there is a much better way to do this.</div><div><br></div><div>Thx </div><div><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Feb 19, 2018 at 12:40 PM, Dietmar Maurer <span dir="ltr"><<a href="mailto:dietmar@proxmox.com" target="_blank">dietmar@proxmox.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">> I've found this:<br>
> RuleDB/Notify.pm: my $qid = PMG::Utils::reinject_mail(<br>
> RuleDB/Accept.pm:     my ($qid, $code, $mess) = PMG::Utils::reinject_mail(<br>
> RuleDB/BCC.pm:     my $qid = PMG::Utils::reinject_mail(<br>
> Utils.pm:sub reinject_mail {<br>
> Utils.pm:    PMG::Utils::reinject_mail ($top, '', [$receiver], undef,<br>
> $data->{fqdn});<br>
><br>
> Do you use the  PMG::Utils::reinject_mai every time in ALL the<br>
> pmg-smtp-filter to reinject ?<br>
<br>
</span>AFAIK yes.<br>
<span class=""><br>
> I've found the var at the top of pmg-filter:<br>
><br>
> my $opt_int_port = 10023;<br>
> my $opt_inject_port = 10025; <--- HERE<br>
><br>
> BUT seems to be not used.<br>
><br>
> I'm planning to distinguish two different smtp port to reinject back, how<br>
> can I figure out inside the function<br>
>  PMG::Utils::reinject_mail which direction (and so which port of<br>
> pmg-filter) I'm using ?<br>
<br>
</span>I guess you need to check all call sites, and maybe you need<br>
to add an extra parameter ...<br>
<div class="HOEnZb"><div class="h5"><br>
______________________________<wbr>_________________<br>
pmg-devel mailing list<br>
<a href="mailto:pmg-devel@pve.proxmox.com">pmg-devel@pve.proxmox.com</a><br>
<a href="https://pve.proxmox.com/cgi-bin/mailman/listinfo/pmg-devel" rel="noreferrer" target="_blank">https://pve.proxmox.com/cgi-<wbr>bin/mailman/listinfo/pmg-devel</a><br>
</div></div></blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature" data-smartmail="gmail_signature">Got problems with Windows? - ReBooT<br>Got problems with Linux? - Be RooT </div>
</div>