Home > database >  Generate EML file for DKIM Signatue
Generate EML file for DKIM Signatue

Time:12-03

Some question's, and articles I've been reading regarding EML creation

I can't seem to find any standalone class files that will generate the contents for *.eml that can be either stored into file (using file_put_contents) or temporarily into a variable.

The idea is that I can create my *.eml file server-side I could use the contents to verify a DKIM signature, without having to actually send an email.

I did find one library phplint that does what I want, but it is far too big for what I need (635 Files, 53 Folders 7.84 MB (8,224,768 bytes)).

$m = new Mailer();
$m->setSubject("This is the subject");
$m->setFrom("[email protected]", "My Name");
$m->addAddress("[email protected]", "Your Name");
$m->setTextMessage("This is the text body of the message.");
$m->sendByStream($out_string, TRUE);
$message_as_string = $out_string->__toString();

The above snippet uses the following classes to generate the message.

[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

I've been looking all over github, as well as PHPClasses. But I can't anything relevant to what I need (with enough research I could probably build it myself but I'd prefer not to reinvent the wheel).

Ideally I'm looking for possibly an extension of PHPMailer, that can stream the EMAIL either to File or String Variable). I also need the class or function to work on both linux and windows.

If somebody can just find a library or point me into the right direction, I'd much appreciate it.

CodePudding user response:

I think I've found what I've been looking for with https://symfony.com/doc/current/mailer.html

   $email = (new Email())
        ->from('[email protected]')
        ->to('[email protected]')
        //->cc('[email protected]')
        //->bcc('[email protected]')
        //->replyTo('[email protected]')
        //->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>";

Although I'm still looking for a single class solution rather downloading an bloatware to fulfil a single task.

  • Related