You need to define variables before you use them!
require "modules/mailer.php";
$email_send = new mailSend();
$subject = "Please verify email!";
$message = "Thanks for signing up!<br>
Please click on the link below:<br><br>
<a href=".$url.">".$url."</a>";
$email_send->sendMail($email,$message,$subject);
To get PHPMailer to throw exceptions, you need to ask it, by passing true
to the constructor:
$mail = new PHPMailerPHPMailerPHPMailer(true);
Now to get responses out of your class, you need to return something, so change the end of your send function to this:
$result = [];
$mail->send();
$result['success'] = true;
$result['message'] = "Mail sent.";
} catch (Exception $e) {
$result['success'] = false;
$result['message'] = "Failed. Mailer error: {$mail->ErrorInfo}";
}
return $result;
Then when you call your function:
$result = $email_send->sendMail($email,$message,$subject);
if ($result['success']) {
echo $result['message'];
//Do whatever else you want to do on success
} else {
echo $result['message'];
}
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…