'phpmailer send mails via OWN mailserver, missing DKIM

i'm using phpmailer V 6.6.0 Here at stackoverflow are a lot of hints and tricks, how to create and use key files for sending DKIM-signed mails.

But my problem is very simple. I can't remember to provide Thunderbird / Livemail / Outlook whatever with a .key-file.

All i want to do is to use phpmailer sending a mail via my mail server. Like all other EMail-Programs do.

This is my code so far:

    $Server = "xxxxxx.xxxxxx.com" ;
    $Username = "mxxxxx" ;
    $Password = "xxxxxxxxxxxx" ;
    
    $mail = new PHPMailer();
    $mail->isSendmail();
    // Define the sender
    $mail->Host = $Server; 
    $mail->Port = 587;
    $mail->SMTPAuth = true;
    $mail->Username = $Username; 
    $mail->Password = $Password; 
    $mail->Hostname = "@thisdomain.com";
    $mail->MessageID = "<".time()."@thisdomain.com>";
    $mail->XMailer="MyMailer";
    //Set who the message is to be sent from
    $mail->setFrom($dbset['Sender']);
    $mail->addReplyTo($dbset['Sender']);
    $mail->addAddress($dbset['Receiver']);
    $mail->Subject = "JUST A TEST";
    $mail->isHTML(false);
    $mail->Body = "This is just a test";
    //send the message, check for errors
    $Res = $mail->send(); 
    if (!$Res) die('VERY BAD - Error sending mail!');
    $mail->__destruct();
    unset($mail);

Well it works great, beside of the "DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1652648844; bh=x8/D1v6jj+heUcnMHbgz3HeVzmgGNIkhaOk...lots of bytes here..."

What am i doing wrong? I don't need to set up an own mail server. My mail server at my provider works great, including the DKIM signature. Why won't it work with phpmailer? Signing the Email is not the job of the client, it should be done at the mail server. Or i'm wrong at this?

Helpless Mac



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source