Hello,
I've tried making my contact form work with PHP and SMTP, but none have worked.
With PHP, I get the:
Email could not be sent due to some Unexpected Error. Please Try Again later.
Reason:
Could not instantiate mail function.
I read in previous tickets that this could be a server issue, so to then try with SMTP settings, but when I entered the settings in my form.php file, the form just greys out and seems to be loading, but times out after a while and nothing happens.
I've attached screenshots for both instances.
Here is my form code:
Name *
Email *
Phone
Message *
Send Message
And here is the form.php code:
/*-------------------------------------------------
PHPMailer Initialization
---------------------------------------------------*/
use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\Exception;
require 'phpmailer/src/Exception.php';
require 'phpmailer/src/PHPMailer.php';
require 'phpmailer/src/SMTP.php';
/*-------------------------------------------------
Receiver's Email
---------------------------------------------------*/
$toemails = array();
$toemails[] = array(
'email' => 'hello@yycbestrenos.ca', // Your Email Address
'name' => 'YYC Best Renos' // Your Name
);
/*-------------------------------------------------
Sender's Email
---------------------------------------------------*/
$fromemail = array(
'email' => 'hello@yycbestrenos.ca', // Company's Email Address (preferably currently used Domain Name)
'name' => 'YYC Best Renos' // Company Name
);
/*-------------------------------------------------
reCaptcha
---------------------------------------------------*/
// Add this only if you use reCaptcha with your Contact Forms
$recaptcha_secret = ''; // Your reCaptcha Secret
/*-------------------------------------------------
hCaptcha
---------------------------------------------------*/
// Add this only if you use hCaptcha with your Contact Forms
$hcaptcha_secret = ''; // Your hCaptcha Secret
/*-------------------------------------------------
PHPMailer Initialization
---------------------------------------------------*/
$mail = new PHPMailer();
/* Add your SMTP Codes after this Line */
$mail->IsSMTP();
$mail->Host = "email.yycbestrenos.ca";
$mail->SMTPDebug = 0;
$mail->SMTPAuth = true;
$mail->SMTPSecure = "ssl";
$mail->Port = 26;
$mail->Username = "hello@yycbestrenos.ca";
$mail->Password = "*MyPassword*";
// End of SMTP