DKIM_sign.phps 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. <?php
  2. /**
  3. * This example shows sending a DKIM-signed message with PHPMailer.
  4. * More info about DKIM can be found here: http://www.dkim.org/info/dkim-faq.html
  5. */
  6. //Import the PHPMailer class into the global namespace
  7. use PHPMailer\PHPMailer\PHPMailer;
  8. require '../vendor/autoload.php';
  9. //Usual setup
  10. $mail = new PHPMailer;
  11. $mail->setFrom('from@example.com', 'First Last');
  12. $mail->addReplyTo('replyto@example.com', 'First Last');
  13. $mail->addAddress('whoto@example.com', 'John Doe');
  14. $mail->Subject = 'PHPMailer mail() test';
  15. $mail->msgHTML(file_get_contents('contents.html'), dirname(__FILE__));
  16. $mail->AltBody = 'This is a plain-text message body';
  17. //See the DKIM_gen_keys.phps script for making a key pair -
  18. //here we assume you've already done that.
  19. //Path to your private key:
  20. $privatekeyfile = 'dkim_private.pem';
  21. //Put your domain in here
  22. $mail->DKIM_domain = 'example.com';
  23. //Put the path to your private key file in here
  24. $mail->DKIM_private = $privatekeyfile;
  25. //Set the selector
  26. $mail->DKIM_selector = 'phpmailer';
  27. //Put your private key's passphrase in here if it has one
  28. //Leave it blank otherwise.
  29. $mail->DKIM_passphrase = '';
  30. //When you send, the DKIM settings will be used to sign the message
  31. //if (!$mail->send()) {
  32. // echo "Mailer Error: " . $mail->ErrorInfo;
  33. //} else {
  34. // echo "Message sent!";
  35. //}