Skip to content

Instantly share code, notes, and snippets.

@suzuki
Created February 2, 2014 23:51
Show Gist options
  • Star 17 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save suzuki/8776887 to your computer and use it in GitHub Desktop.
Save suzuki/8776887 to your computer and use it in GitHub Desktop.
Swift Mailer sample / DKIM email
<?php
require 'vendor/autoload.php';
$transport = Swift_SmtpTransport::newInstance('localhost', 25);
$mailer = Swift_Mailer::newInstance($transport);
// DKIM 用の Signer を作成する
$privateKey = file_get_contents('./default.private');
$domainName = 'example.com';
$selector = 'default';
$signer = new Swift_Signers_DKIMSigner($privateKey, $domainName, $selector);
// 署名用の Message インスタンスを作成
$message = Swift_SignedMessage::newInstance();
// DKIM Signer をアタッチ
$message->attachSigner($signer);
$message
->setFrom(['suzuki@example.com'])
->setTo(['YOUR_GMAIL_ADDRESS'])
->setSubject('テストメール')
->setBody('テストメール本文')
;
$result = $mailer->send($message);
@yebt
Copy link

yebt commented Nov 1, 2022

Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment