Im building a site and I need to implement a form sending option, after a lot of research I settled on PHPMAILER. I set my script to work with my gmail address for testing purposes and it works fine, but when I inputted the clients email details it doesnt work.
When I submit the application, this is what i am getting
SMTP -> ERROR: Failed to connect to server: Connection refused (111)
I contacted support and verified the port and host, and contacted the client and verified the login info. Is there another reason why it might not be working?
Update I made a small script that allows me to easily test settings
<?php
require 'classes/class.phpmailer.php';
require 'classes/class.smtp.php';
$mail = new PHPMailer(true);
$mail->IsSMTP();
try{
$mail->SMTPDebug = 1;
$mail->SMTPAuth = true;
//$mail->SMTPSecure = "ssl";no
$mail->Host = "smtp.domain.com";
$mail->Port = 25;
$mail->Username = "username";//user@domain.com
$mail->Password = "pwd";
$mail->AddAddress('alme1304@gmail.com');//RECIPIENT
//$mail->SetFrom('name@yourdomain.com', 'First Last');//IDK WHAT 'THIS' IS FOR
//$mail->AddReplyTo($_POST['email'], $_POST['f_name'].' '.$_POST['l_name']);//FOR THE 'REPLY-TO' FIELD
$mail->Subject = 'test email';
$mail->MsgHTML('test_email');
$mail->Send();
} catch (phpmailerException $e) {
echo $e->errorMessage(); //Pretty error messages from PHPMailer
echo $mail->Host;
echo '<pre>';
print_r($mail);
echo '</pre>';
} catch (Exception $e) {
echo $e->getMessage(); //Boring error messages from anything else!
}
I have had experiences with hosts who claim you can use smtp.domain.com yet you cannot. Instead of smtp.domain.com, use the hosting provider's SMTP servers (you can usually get these from their knowledge base or support)
Also verify the port, many do not use 25 but may use 26, or some other (get from knowledge base or support)
We may be of better assistance if you let us know who the hosting provider is