php.ini
mail.log = "c:/wamp/logs/maillog.log"
PHPMailer_Email.php (Using below script, it doesn’t write log in specified file but send email.)
include 'vendor/autoload.php';
$mail = new PHPMailer;
$mail->isSMTP();
$mail->SMTPDebug = 2;
$mail->Host = "domain.example.net";
$mail->Port = 25;
$mail->From = $from;
$mail->FromName = "From Name";
$mail->addAddress($to);
$mail->addReplyTo($from, "Reply");
$mail->isHTML(true);
$mail->Subject = $subject;
$mail->Body = $body;
$mail->AltBody = $body;
if(!$mail->send()){
echo "Mailer Error: ". $mail->ErrorInfo; die();
}
else{
echo "Message has been sent successfully";
}
Email.php (Using below script, it write log and also send email)
mail($to, $subject, $body);
Could anyone suggest how I can enable PHPMailer to write mail log in maillog.log file?