Send email by PHPMailer (v2019)

Have custom files that were using the old cEMail class and now am converting to requirementsbut keep receiving “Could not instantiate mail function.” - can’t figure out what is miss now. do I need to manually add the smtp account info from ewcfg15.php ?

	$Email = new \PHPMailer\PHPMailer\PHPMailer();
	$Email->isHTML(true);

	$Email->setFrom($msgHeader['sender']); // Replace Sender

	$Email->addAddress($msgHeader['recipient']); // Replace Recipient
	
	$Email->Subject = $msgHeader['subject']; // Replace Subject
	$Email->Body = $msgHeader['content'];

	$bEmailSent = $Email->send();
	
	if($bEmailSent) {  ...  }

added the following items but these items are not returning the correct data:ex:
Port: returns “PHPMaker2019\electron2\587”
Password: returns “PHPMaker2019\electron2\SMTP_SERVER_PASSWORD”$Email->SMTPAuth = true;
$Email->SMTPAutoTLS = true;
$Email->Port = PROJECT_NAMESPACE . SMTP_SERVER_PORT;
$Email->Host = PROJECT_NAMESPACE . ‘SMTP_SERVER’;
$Email->Username = PROJECT_NAMESPACE . ‘SMTP_SERVER_USERNAME’;
$Email->Password = PROJECT_NAMESPACE . ‘SMTP_SERVER_PASSWORD’;
$bConnected = $Email->smtpConnect();

If you set the advanced setting “PHPMailer mailer” as “mail” or “sendmail”, make sure you have set up the email function of your PHP (in php.ini) properly and it works properly first. Otherwise, you’d better use the default “smtp” setting which uses the SMTP server settings you specify in your PHPMaker project.

thanks, got it working.not sure why it didn’t work the first time.I reset the code back to this, this morning:

    $Email = new Email();
        
	$Email->replaceSender($msgHeader['sender']); // Replace Sender
	$Email->addRecipient($msgHeader['recipient']); // Replace Recipient

etc…
$bEmailSent = $Email->send();and it worked using all the settings from the ewcfg15 config file.thanks.

$Email = config(“SMTP”);
$Email[“SERVER”] = “HOST”;
$Email[“SERVER_PORT”] = “PORT”;
$Email[“SECURE_OPTION”] = “SSL”;
$Email[“SERVER_USERNAME”] = “USERNAME”;
$Email[“SERVER_PASSWORD”] = “PASSWORD”;This one ?