I’m encountering difficulties integrating my Gmail account for sending emails through my application, which is hosted with GoDaddy. My aim is to properly set the outbound email settings using my Gmail credentials. However, I keep receiving an error stating that the SMTP connection could not be established. I’ve tried various troubleshooting methods, but the problem persists. Here’s an example of the code I’m using, which may need adjustments:
<?php
include 'EmailDispatcher.php';
$emailSender = new EmailDispatcher();
$emailSender->configureServer('smtp.gmail.com', 587);
$emailSender->setAuth('[email protected]', 'securePassword');
if (!$emailSender->initiateMail()) {
echo 'Failed to connect to the SMTP server. Please verify your configurations.';
} else {
echo 'Email sent successfully using Gmail outbound settings!';
}
?>
I would appreciate any guidance on resolving this SMTP configuration issue.