wordpress内でcompserを用いてメールの送信機能を作りたいのですがうまくいきません。。。
1.自分が行ったこと
1.1 composer.bat compser.phar を C:\xampp\phpに保存
1.2 cmdを用いてcomposerをinstall
1.3 composer.jsonを作成、以下にコード記載
json
1{ 2 "require": { 3 "aws/aws-sdk-php": "*", 4 "firegoby/add-rewrite-ep": "dev-master" 5 } 6}
1.4 cmdを開き、composerをもう一度install
1.5 C:\xampp\php\vendorが作成される
2.phpコードについて
phpコードについて以下に記載する。書いている箇所についてはC:\xampp\htdocs\test\sample\wp-content\themes\twentyseventeen です。
またphpMailerからdownloadしたException.php、PHPMailer.php、SMTP.phpについても同階層に記述しております。
php
1mb_internal_encoding("UTF-8"); 2require('C:/xampp/php/vendor/autoload.php'); 3require 'Exception.php'; 4require 'PHPMailer.php'; 5require 'SMTP.php'; 6 7$from = "mail"; //差出人 8$fromname = "値"; //差し出し人名 9 10$mailSend = new PHPMailer\PHPMailer\PHPMailer(true); 11$mailSend->CharSet = "iso-2022-jp"; 12$mailSend->Encoding = "7bit"; 13 14$mailSend->IsSMTP(); //「SMTPサーバーを使うよ」設定 15$mailSend->SMTPAuth = TRUE; //「SMTP認証を使うよ」設定 16$mailSend->Host = 587; // SMTPサーバーアドレス:ポート番号 17$mailSend->Username = 'mail'; // SMTP認証用のユーザーID 18$mailSend->Password = 'pass'; // SMTP認証用のパスワード 19 20$mailSend->AddAddress($mail); 21$mailSend->From = $from; 22$mailSend->FromName = mb_encode_mimeheader(mb_convert_encoding($fromname,"JIS","UTF-8")); 23$mailSend->Subject = mb_encode_mimeheader(mb_convert_encoding($mailTitle,"JIS","UTF-8")); 24$mailSend->Body = mb_convert_encoding($mailContent,"JIS","UTF-8"); 25 26//メールを送信 27$mailSend->Send();
3.errorについて
error内容については
PHPMailer\PHPMailer\Exception: SMTP connect() failed.
と出てきます。どうぞご助力お願いします。
回答1件
あなたの回答
tips
プレビュー