<div dir="ltr"><div class="gmail_extra">Hi, Jules!</div><div class="gmail_extra"><br></div><div class="gmail_extra">Yes, we did indeed use MailScanner for quite a few years, I think stopping when we changed from Sendmail to Exim (circa 2007), and definitely when we moved to using G Suite. You hav a good memory! :-)</div><div class="gmail_extra"><br></div><div class="gmail_extra">Looking at the ChangeLog for our ZendTo we&#39;re running 4.20-6 so don&#39;t have the PHPMailer stuff in our installation at present. We should probably see about updating over our summer vacation period when the students are away.</div><div class="gmail_extra"><br></div><div class="gmail_extra">So I&#39;m only able to look only at the PHPMailer documentation and source code itself, without the context of being in the ZendTo source or the joy of knowing PHP…</div><div class="gmail_extra"><br></div><div class="gmail_extra">It looks like you need to set the &quot;Sender&quot; attribute to the address you want to use in the RFC5321.MailFrom, but I can&#39;t see a function to do that. Instead I can only see <b>setFrom()</b> which takes a third Boolean argument. If this is true and Sender is still empty then Sender gets set to the email address supplied for the From.</div><div class="gmail_extra"><br></div><div class="gmail_extra">So, fabricating some sort of horrible fictitious pseudocode, maybe something like this…</div><div class="gmail_extra"><br></div><div class="gmail_extra"><font size="1" face="monospace, monospace">if ($personUploadingIsLoggedIn &amp;&amp;</font></div><div class="gmail_extra"><font size="1" face="monospace, monospace">    $personUploadingEmailAddress &lt;matches your internal domains pattern/list&gt;) {</font></div><div class="gmail_extra"><div class="gmail_extra"><font face="monospace, monospace" size="1">        $mail-&gt;setFrom(</font><span style="font-family:monospace,monospace;font-size:x-small">$personUploadingEmailAddress</span><span style="font-family:monospace,monospace;font-size:x-small">);</span></div><div class="gmail_extra"><span style="font-family:monospace,monospace;font-size:x-small">    } else {</span></div><div class="gmail_extra"><font face="monospace, monospace" size="1">        $mail-&gt;setFrom(</font><span style="font-family:monospace,monospace;font-size:x-small">$</span><font face="monospace, monospace" size="1">envelopeSenderAddress);</font></div><div class="gmail_extra"><span style="font-family:monospace,monospace;font-size:x-small">    }</span></div><div class="gmail_extra"><span style="font-family:monospace,monospace;font-size:x-small">$mail-&gt;setFrom(...arguments as you have now to set the RFC5322.From...);</span></div></div><div class="gmail_extra"><br></div><div class="gmail_extra">where</div><div class="gmail_extra"><ul><li>$personUploadingIsLoggedIn is a variable or test saying whether the person performing the upload is logged in (true) or doing their upload without logging in (false)<br><br></li><li>$personUploadingEmailAddress is the email address and textual name of the logged in person doing the upload (which you clearly have somewhere as it&#39;s shown in the <i>Your email address</i> area of the <i>Information about the Sender</i> page when a logged in user is preparing their upload, and presumably trust it as it&#39;s obtained from the logged in user&#39;s directory details and is used elsewhere)<br><br></li><li>$envelopeSenderAddress is a new preference setting where you can set the RFC5321.MailFrom address to be used as the sender address in the SMTP envelope. (Or else extract the address field from the variable holding the EmailSenderAddress preference, although this might be fiddly.)<br><br></li><li>$serviceTitle is the variable holding the ServiceTitle preference&#39;s value.<br></li></ul><div>If I&#39;ve got this right then the first call to $mail-&gt;setFrom() sets:</div><div><ul><li>the RFC5322.From details to either $personUploadingEmailAddress and an empty descriptive name, or to $envelopeSenderAddress and an empty descriptive name (these are stored in the From and FromName attributes of the message object)<br><br></li><li>the RFC5321.MailFrom to either $personUploadingEmailAddress, or to $envelopeSenderAddress (this is stored in the Sender attribute of the message object)</li></ul><div>Then the second call to $mail-&gt;setFrom() sets the RFC5322.From details to whatever you supply here (use the values as you are right now), and <u>doesn&#39;t</u> change the RFC5321.MailFrom address as that&#39;s no longer empty.</div><div><br></div><div>(The code in class.phpmailer.php in the setMail function tests whether the third parameter is set, or has defaulted to true <u>and</u> the Sender value is empty before changing it. So by setting Sender using the first call it shouldn&#39;t get changed by the second call.)</div></div><div><br></div><div>Hopefully this will let you set the RFC5321.MailFrom to the address Non-Delivery Reports should go to, and the RFC5322.From as you&#39;re doing right now. (If it doesn&#39;t, try setting the third argument of the second call to setMail() to false, which will force it not to alter the already set value of Sender.)</div><div><br></div><div>It does rely on you having a trustworthy email address for a user who has logged into the service though.</div><div><br></div><div>Sorry if that&#39;s very wooly: trying to fathom the PHP code and the time of day is making my brain hurt and tryping desentigrat. :-)</div><div><br></div><div>Cheese,</div><div>Mike B-)</div></div><div class="gmail_extra"><br></div><div class="gmail_extra"><br><div class="gmail_quote">On 22 June 2017 at 17:11, Jules <span dir="ltr">&lt;<a href="mailto:Jules@zend.to" target="_blank">Jules@zend.to</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div bgcolor="#FFFFFF">Mike,<br>
    <br>
    Long time no talk. Didn&#39;t you folks used to run MailScanner? :-)<br>
    <br>
    The new code only uses PHP&#39;s mail() if the SMTP settings are not set
    in preferences.php.<br>
    If they are set at all, it now uses PHPmailer instead.<br>
        <a class="gmail-m_-4375391278853060165moz-txt-link-freetext" href="https://github.com/PHPMailer/PHPMailer" target="_blank">https://github.com/PHPMailer/<wbr>PHPMailer</a><br>
    <br>
    On the basis that PHPMailer can do many more clever things, do you
    fancy having a read of the docs there and suggesting an improvement
    that I could make when using PHPMailer?<br>
    <br>
    Thanks!<br>
    Jules.</div></blockquote></div><div><br></div>-- <br><div class="gmail_signature"><div dir="ltr"><div><font color="#666666">Systems Administrator &amp; Change Manager</font></div><div><font color="#666666">IT Services, University of York, Heslington, York YO10 5DD, UK</font></div><div><font color="#666666">Tel: +44-(0)1904-323811</font></div><div><font color="#666666"><br></font></div><div><font color="#666666">Web:<span style="white-space:pre">                </span><a href="http://www.york.ac.uk/it-services" target="_blank">www.york.ac.uk/it-services</a></font></div><div><font color="#666666">Disclaimer:<span style="white-space:pre">        </span><a href="http://www.york.ac.uk/docs/disclaimer/email.htm" target="_blank">www.york.ac.uk/docs/disclaimer/email.htm</a></font></div></div></div>
</div></div>