Created
February 2, 2014 23:51
-
-
Save suzuki/8776887 to your computer and use it in GitHub Desktop.
Swift Mailer sample / DKIM email
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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(['[email protected]']) | |
->setTo(['YOUR_GMAIL_ADDRESS']) | |
->setSubject('テストメール') | |
->setBody('テストメール本文') | |
; | |
$result = $mailer->send($message); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks