Mail couldnt send to gmail and yahoo using PHPMailer from Smartweb Shared server

the mail() function

Moderators: egami, macek, gesf

Post Reply
nkayode1977
New php-forum User
New php-forum User
Posts: 1
Joined: Thu Jul 30, 2020 11:37 am

Thu Jul 30, 2020 1:52 pm

I’ve setup PHPMailer on my site but does not send messages. it works in local host but not on my live site. it also does not output any error messages to help me troubleshoot.

I tried to use the same script to send mail to 3 different emails(yahoo, gmail and my domain email), the mail only delivers to my domain email account but both gmail and yahoo do not deliver.

Below is my script

$email = "dada****@gmail.com";

$mail = new PHPMailer(true);

$mail->isSMTP();
$mail->SMTPDebug = SMTP::DEBUG_OFF;
$mail->Host = "domain smtp server";
$mail->Port = 465;
$mail->SMTPAuth = false;
$mail->isHTML(true);
$mail->Username = "xxxxxxx@xxxxxxxxxxxx";
$mail->Password = "xxxxxxxx";
$mail->SMTPSecure = "ssl";
$mail->Subject = "Verify Account Creation";
// To send HTML mail, the Content-type header must be set
$mail->setFrom($constant['SR_EMAIL_REPLY'], 'xxxxxxxxx');
$mail->addReplyTo($constant['SR_EMAIL_INFO'], 'xxxxxxxxx');
//$headers[] = 'MIME-Version: 1.0';
// Additional headers
$mail->Body = '<h1>Testing the PHPMailer</h1>';
$mail->addAddress($email, 'xxxxxx');

//$headers[] = $email;
//$headers[] = 'From: '. $constant['SR_EMAIL_INFO'];
//$headers[] = 'Cc: '. $constant['SR_EMAIL'];
if(!$mail->send()) {
echo('Mailer Error: ' . $mail->ErrorInfo);
} else {
echo('Mail sent to your registered email successfully. Kindly check your mail and activate your account.<br \/><br \/><br \/><br \/><br \/><br \/>');
}

Please has anybody experienced this. what is being done to correct that? is there anything that needs to be done at the shared server's end? Pls kindly share your experience.
Post Reply