为 DKIM 签名生成 EML 文件

Generate EML file for DKIM Signatue

我一直在阅读有关 EML 创建的一些问题和文章

我似乎找不到任何独立的 class 文件来生成 *.eml 的内容,这些内容可以存储到文件中(使用 file_put_contents)或临时存储到variable.

我的想法是我可以在服务器端创建我的 *.eml 文件我可以使用内容来验证 DKIM 签名,而不必实际发送 email.

我确实找到了一个库 phplint 可以满足我的需求,但它对于我需要的东西来说太大了 (635 Files, 53 Folders 7.84 MB (8,224,768 bytes))。

$m = new Mailer();
$m->setSubject("This is the subject");
$m->setFrom("my@mydomain.com", "My Name");
$m->addAddress("you@yourdomain.com", "Your Name");
$m->setTextMessage("This is the text body of the message.");
$m->sendByStream($out_string, TRUE);
$message_as_string = $out_string->__toString();

以上代码段使用以下 classes 生成消息。

[180] => it\icosaedro\email\Mailer
[181] => it\icosaedro\io\IOException
[182] => it\icosaedro\utils\StringBuffer
[183] => it\icosaedro\io\OutputStream
[184] => it\icosaedro\io\StringOutputStream
[185] => it\icosaedro\email\Field
[186] => it\icosaedro\email\MIMEAbstractPart
[187] => it\icosaedro\email\Header
[188] => it\icosaedro\email\MIMEPartMemory
[189] => it\icosaedro\email\EOLFilter
[190] => it\icosaedro\utils\Random

我一直在寻找 github,还有 PHPClasses。但是我不能做任何与我需要的相关的事情(通过足够的研究,我可能会自己构建它,但我不想重新发明轮子)。

理想情况下,我正在寻找可能的 PHPMailer 扩展,它可以将 EMAIL 流式传输到文件或字符串变量)。我还需要 classfunction 来处理 linuxwindows.

如果有人能找到图书馆或为我指明正确的方向,我将不胜感激。

我想我已经找到了我一直在寻找的 https://symfony.com/doc/current/mailer.html

   $email = (new Email())
        ->from('hello@example.com')
        ->to('you@example.com')
        //->cc('cc@example.com')
        //->bcc('bcc@example.com')
        //->replyTo('fabien@example.com')
        //->priority(Email::PRIORITY_HIGH)
        ->subject('Time for Symfony Mailer!')
        ->text('Sending emails is fun again!')
        ->html('<p>See Twig integration for better HTML integration!</p>');

    echo "<pre>";
    print_r($email->toString());
    echo "</pre>";

尽管我仍在寻找单一 class 解决方案,而不是下载英国媒体报道软件来完成单一任务。