modMail to insert List-Unsubscribe header

Hi, i’m developing a snippet to send a email to an eligable person for voting on a subject.
I want to insert a header in the email “List-Unsubscribe” with a value. Anyone know how to insert this header?

$modx->getService('mail', 'mail.modPHPMailer');
$modx->mail->set(modMail::MAIL_FROM_NAME,'My website name');
$modx->mail->set(modMail::MAIL_SUBJECT,'Subject for the email');
$modx->mail->address('to','eligableperson@hisdomainname.tld', 'Name person');
if (!$modx->mail->send()) {
    $modx->log(modX::LOG_LEVEL_ERROR,'Fout bij verzenden email: '.$modx->mail->mailer->ErrorInfo);

I haven’t tested it, but the class “modPHPMailer” has a function “header”.

So you probably have to call $modx->mail->header() and it seems that the header must have the format name:value (name and value separated by a colon :).

The Subscribe extra (in conjunction with the Notify extra) puts an unsubscribe link in the text of the email. The link is obfuscated and contains an encoded key to identify the user, otherwise, bad actors could unsubscribe people. The class is here, but you may have to look at other parts of the two extras to understand it.