In php , I use SwiftMailer to send verification email to every users . I tested a lot with original email accounts like @gmail.com , @hotmail.com.
But on custom domain email account like @belkin.com doesn't receive the emails. I don't know the reason why. How can I resolve this problem? This is my code.
<?php
require_once './vendor/autoload.php';
$transport = (new Swift_SmtpTransport('smtp.gmail.com', 465, 'ssl'))
->setUsername('***@gmail.com')
->setPassword('***');
// Create the Mailer using your created Transport
$mailer = new Swift_Mailer($transport);
function sendVerificationEmail($userEmail, $token)
{
global $mailer;
$body = '<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Test mail</title>
<style>
.wrapper {
padding: 20px;
color: #444;
font-size: 1.3em;
}
a {
background: #592f80;
text-decoration: none;
padding: 8px 15px;
border-radius: 5px;
color: #fff;
}
</style>
</head>
<body>
<div class="wrapper">
<p>Thank you for signing up on our site. Please click on the link below to verify your account:.</p>
<a href="http://localhost/cwa/verify-user/verify_email.php?token=' . $token . '">Verify Email!</a>
</div>
</body>
</html>';
// Create a message
$message = (new Swift_Message('Verify your email'))
->setFrom('***@gmail.com')
->setTo($userEmail)
->setBody($body, 'text/html');
// Send the message
$result = $mailer->send($message);
if ($result > 0) {
return true;
} else {
return false;
}
}
?>
I tried a lot but I don't know the reason why. The swiftmailer return TRUE if I send email to custom domain email address but on that account there is no email. How can I resolve this?