DKIM.phps 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. <?php
  2. /**
  3. * This example shows how to use DKIM message authentication with PHPMailer.
  4. * There's more to using DKIM than just this code - check out this article:
  5. * @link https://yomotherboard.com/how-to-setup-email-server-dkim-keys/
  6. * See also the DKIM code in the PHPMailer unit tests,
  7. * which shows how to make a key pair from PHP.
  8. */
  9. require '../PHPMailerAutoload.php';
  10. //Create a new PHPMailer instance
  11. $mail = new PHPMailer;
  12. //Set who the message is to be sent from
  13. $mail->setFrom('from@example.com', 'First Last');
  14. //Set an alternative reply-to address
  15. $mail->addReplyTo('replyto@example.com', 'First Last');
  16. //Set who the message is to be sent to
  17. $mail->addAddress('whoto@example.com', 'John Doe');
  18. //Set the subject line
  19. $mail->Subject = 'PHPMailer DKIM test';
  20. //This should be the same as the domain of your From address
  21. $mail->DKIM_domain = 'example.com';
  22. //Path to your private key file
  23. $mail->DKIM_private = 'dkim_private.pem';
  24. //Set this to your own selector
  25. $mail->DKIM_selector = 'phpmailer';
  26. //If your private key has a passphrase, set it here
  27. $mail->DKIM_passphrase = '';
  28. //The identity you're signing as - usually your From address
  29. $mail->DKIM_identity = $mail->From;
  30. //send the message, check for errors
  31. if (!$mail->send()) {
  32. echo "Mailer Error: " . $mail->ErrorInfo;
  33. } else {
  34. echo "Message sent!";
  35. }