私は非常に多くの異なるアプローチを試しましたが、関数を使用してPHPでSMTPを介して電子メールを正常に送信できませんmail()
。
<?php
require_once ABSPATH . WPINC . '/class-phpmailer.php';
require_once ABSPATH . WPINC . '/class-smtp.php';
$phpmailer = new PHPMailer();
$phpmailer->SMTPAuth = true;
$phpmailer->Username = 'skchourasia@asselslutions.com';
$phpmailer->Password = 'password01';
$phpmailer->IsSMTP(); // telling the class to use SMTP
$phpmailer->Host = "mail.asselsolutions.com"; // SMTP server
$phpmailer->FromName = $_POST[your_email];
$phpmailer->Subject = $_POST[your_subject];
$phpmailer->Body = $_POST[your_message]; //HTML Body
$phpmailer->AltBody = "To view the message, please use an HTML compatible email viewer!"; // optional, comment out and test
$phpmailer->WordWrap = 50; // set word wrap
$phpmailer->MsgHTML($_POST[your_message]);
$phpmailer->AddAddress('support@wordpressapi.com/files/', 'Wordpress support');
//$phpmailer->AddAttachment("images/phpmailer.gif"); // attachment
if(!$phpmailer->Send()) {
echo "Mailer Error: " . $phpmailer->ErrorInfo;
} else {
echo "Message sent!";
}
$to = $_REQUEST['to'];
$subject = $_REQUEST['subject'];
$message = $_REQUEST['message'];
$from = $_REQUEST['from'];
$headers = "From:" . $from;
$mail = mail($to,$subject,$message,$headers);
echo "Mail Sent.";
?>
私は何が間違っているのですか?次のエラーが発生します。
解析エラー:構文エラー、8行目のC:\ xampp \ htdocs \ wp-vtr \ wp-content \ themes \ twintyeleven\content.phpの予期しないT_VARIABLE
$phpmailer->IsSMTP(); // telling the class to use SMTP"