A beginner here.
I have already checked the forum to find out answers but I was not successful, other questions were specifically on some parts of PHPMailer but mine is more general. So I hope no one will mark my question as duplicate as I am in learning curve.
I am working on a PHP project. How it works is that the user goes to the page and writes some comments or issues in a form (like a text editor) and clicks on the send button. I should be able to receive his message to my email. I have set my Gmail account here for testing purposes but later it will be my real email with my own domain.
Here is the error that I am receiving when I run on local host:
Fatal error: Uncaught exception 'phpmailerException' with message 'Could not execute: /usr/sbin/sendmail' in C:\xampp\htdocs\pp\classes\class.phpmailer.php:1100 Stack trace: #0 C:\xampp\htdocs\pp\classes\class.phpmailer.php(1026): PHPMailer->sendmailSend('Date: Thu, 9 Oc...', '--b1_9ea0b33e3f...') #1 C:\xampp\htdocs\pp\classes\class.phpmailer.php(935): PHPMailer->postSend() #2
Here is the code I am using:
<?php
require_once("../../classes/class.phpmailer.php");
if($_POST['mode']=='send'){
$mail = new PHPMailer(true); // the true param means it will throw exceptions on errors, which we need to catch
$mail->IsSendmail(); // telling the class to use SendMail transport
//I assume this part is to make it run on linux base on Google search
$body = "New Bug Report from ".$_SESSION['name']."\n".$_POST['bug'];
$mail->AddReplyTo('mj@gmail.com', 'MJ Team');
$mail->AddAddress(''.$_SESSION['email'].'', ''.$_SESSION['name'].'');
$mail->SetFrom(mj@gmail.com', 'MJ Team');
$mail->AddReplyTo('mj@gmail.com', 'MJ Team');
$mail->Subject = 'New bug report for the portal';
$mail->AltBody = 'To view the message, please use an HTML compatible email viewer!'; // optional - MsgHTML will create an alternate automatically
$mail->MsgHTML($body);
$mail->Send();
//And I assume this part of the code makes it run on windows based on Google search
$mail->IsSMTP();
$mail->SMTPAuth = true;
$mail->Host = "smtp.postmarkapp.com";
$mail->Port = 26;
$mail->Username = "MJ";
$mail->Password = "MJ";
$mail->SetFrom('mj@gmail.com', 'mj');
$mail->Subject = "An email for test";
$mail->AddAddress($address, $name);
if($mail){
$message = 'Thanks. Bug report successfully sent. We will get in touch if we have any more questions.';
}
else {
echo "Mailer Error: " . $mail->ErrorInfo;
}
}
?>
Just as extra information I was not able to find any user and pass for SMTP so I just filled with with my name which obviously shouldn't be right. Since I am beginner I appreciate any comments and suggestion code that might help me run my code.
Thank you!