MAMPなどのメールが送れないテスト環境から、メールを送りたい場合、mailjetやsendgridなどがすぐに設定できると便利。
手持ちのドメイン(hogehoge.com)から、mailjetを使ってメール送信する方法メモ。
GMOではonamae.comやムームードメインもあるが、value-domainが一番無駄がなくわかりやすいと思う。
まずドメインを所有している確認。mailjetの表示に従い、value-domainのDNSを更新。
txt mailjet._******** hogehoge.com ********************************
して、保存。mailjetでドメインを認証。
次に、SPFとDomainKeys/DKIMの設定。画面の内容を確認し
txt @ v=spf1 include:spf.mailjet.com ?all txt mailjet._domainkey k=rsa; p=************************************************************************************
しばらくしてmailjetでFORCE RELOADすると、

あとは、SMTP設定を使う。
WordPressなら、WP SMTPプラグインを使ったり、phpmailer_init hook で定義したり。
add_action( 'phpmailer_init', 'send_smtp_email' );
function send_smtp_email( $phpmailer ) {
if ( ! is_object( $phpmailer ) ) {
$phpmailer = (object) $phpmailer;
}
$phpmailer->IsSMTP();
$phpmailer->Host = SMTP_HOST;
$phpmailer->SMTPAuth = SMTP_AUTH;
$phpmailer->Port = SMTP_PORT;
$phpmailer->Username = SMTP_USER;
$phpmailer->Password = SMTP_PASS;
$phpmailer->SMTPSecure = SMTP_SECURE;
$phpmailer->From = SMTP_FROM;
}
