PHPMailer Issue
Hello Everyone,
Can somebody, Please look into my mailing script below and let me know what is wrong with it for cpanel to throw various different errors like :-
CLIENT: 220, SMTP Error: Could not connect to SMTP host, SMTP connect() failed.
The script refuses to work :(, What wrong am i doing here, Please suggest !
I created the script:
example.com/razvoj/web_stranice/nullboxv1/funkcije/email2.php
PHP SCRIPT:
Appreciate your time guys, Thank you
SMTPDebug =3; // Enable verbose debug output
$mail->isSMTP(); // Set mailer to use SMTP
$mail->Host = 'localhost'; // Specify main and backup SMTP servers
$mail->SMTPAuth = true; // Enable SMTP authentication
$mail->Username = 'ME@mydomain.com[/EMAIL]'; // SMTP username
$mail->Password = 'somepassword'; // SMTP password
$mail->SMTPSecure = 'tls'; // Enable TLS encryption, ssl also accepted
$mail->Port = 587; // TCP port to connect to
$mail->setFrom('ME@mydomain.com[/EMAIL]', 'Mailer');
$mail->addAddress('SOMEGMAILID@gmail.com[/EMAIL]'); // Name is optional
//$mail->addReplyTo('info@hostname.com[/EMAIL]', 'Information');
//$mail->addCC('*******@gmail.com');
//$mail->addBCC('bcc@example.com[/EMAIL]');
//$mail->addAttachment('/var/tmp/file.tar.gz'); // Add attachments
//$mail->addAttachment('/tmp/image.jpg', 'new.jpg'); // Optional name
$mail->isHTML(true); // Set email format to HTML
$mail->Subject = 'Here is the subject';
$mail->Body = 'This is the HTML message body in bold!';
$mail->AltBody = 'This is the body in plain text for non-HTML mail clients';
if(!$mail->send()) {
echo 'Message could not be sent.';
echo 'Mailer Error: ' . $mail->ErrorInfo;
exit();
} else {
echo 'Message has been sent';
}
?>
Appreciate your time guys, Thank you
-
$mail->Port = 587; // TCP port to connect to
Hello, Have you tried switching to port 25 to see if you encounter the same error message? Also, I do see that debug mode is enabled. Is there any additional output you see when testing the script other than the error message you provided? Thank you.0 -
Thank you so very much for your reply Michael, I shall have this checked out tomorrow when i reach office and will get back to you on this. Highly appreciate your response. Thank you, 0 -
Hello Michael, I went ahead and changed the port number to 25 and also changed the debug value to 0, and now this is what i see on the screen after i call the script in the browser :- Message could not be sent.Mailer Error: SMTP connect() failed. Troubleshooting " PHPMailer/PHPMailer Wiki " GitHub What next can be done, Please suggest. Thank you 0 -
Hello, It's actually more helpful to set the debug mode to "3" to ensure more verbose log details are provided. Do you have any firewall rules blocking local access to port 25? Thank you. 0
Please sign in to leave a comment.
Comments
4 comments