You are on page 1of 1

If you getting any error alert like below when you run this on a live host server.

There can be multiple reasons for that. If you are running this on a live host, you
have to use the necessary settings in your host service. Because the settings of
the host services are different from one to another. Read this.

"SMTP Error: Could not authenticate."


"SMTP Error: Could Not Connect to SMTP Host"

If you get these errors when you try on a live host. This might be helpful.

In your host > go to cpanel > Email Accounts > Webmail > Configure Mail Client

Then you can find Secure SSL/TLS Settings (Recommended).


From that settings use settings below.

● Username (Web Email Address)


● Password (Web email Password)
● Outgoing Server
Host can be yourdomain.com / mail.yourdomain.com
SMTP Port: Can be 465/587

*you can use a Gmail or any email address to receive emails.

After you change codings it can be look like below.

$mail->isSMTP();
$mail->Host = 'yourdomain.com'; // Can be mail.yourdomain.com
$mail->SMTPAuth = true;
$mail->Username = 'webmail@domain.com'; // Your host email account which you want
to use as SMTP server
$mail->Password = 'host email password'; // host email account password
$mail->SMTPSecure = 'ssl'; // Can be tls
$mail->Port = 465; // Can be 587

$mail->setFrom('webmail@domain.com'); // Your host email account which you used


as SMTP server
$mail->addAddress('youranyemail@email.com'); // Email Address where you want to
receive emails (You can use any other email address to receive emails)

You might also like