0

I have tried the following code below on my local machine and it works fine, but when i host it on yahoo small business it keeps giving "SMTP connect() failed". what can i do?

 $mail             = new PHPMailer();
              $body             = $message;
              $mail->IsSMTP();
              $mail->SMTPAuth   = true;
              $mail->Host       = "smtp.bizmail.yahoo.com"; //Outgoing mail (SMTP) server
              $mail->Port       = 465;
              $mail->Username   = "myadminmail@mydomain.net";
              $mail->Password   = "mypassword";
              $mail->SMTPSecure = 'tls';
              $mail->SetFrom('myadminmail@mydomain.net', 'name',false);
              $mail->Subject    = $subject;
              $mail->AltBody    = "Any message.";
              $mail->MsgHTML($body);

              $address = $to;
              $mail->AddAddress($address, $name);
              if(!$mail->Send()) {
                  echo 'Mailer Error: ' . $mail->ErrorInfo;
              } else {
                    echo 'Mailer Sent: ' ;
             }
chikor.net
  • 357
  • 9
  • 20
  • [Read and do](https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting). – Siguza Aug 04 '15 at 09:47
  • You could try [reading the docs](https://github.com/PHPMailer/PHPMailer/wiki), or some of the 800 previous SO questions found when you search for this message. – Synchro Aug 04 '15 at 09:55
  • possible duplicate of [SMTP connect() failed PHPmailer - PHP](http://stackoverflow.com/questions/22927634/smtp-connect-failed-phpmailer-php) – Synchro Aug 04 '15 at 09:57

3 Answers3

0

Ok thanks everyone i got it to work by removing this line $mail->IsSMTP();

chikor.net
  • 357
  • 9
  • 20
0

change line:

 $mail->IsSMTP();

for:

 $mail->isMail(true);
0

This works for me:

$mail->SMTPDebug = 1;
$mail->isMail(true);
$mail->SMTPSecure = "ssl";
$mail->Port = 587;
$mail->Host = "smtp.bizmail.yahoo.com"; // SMTP server

Then, you have to login to your Yahoo account and then follow this link:

https://login.yahoo.com/account/security#other-apps

Activate "Allow aplications with less security".

Gleb Kemarsky
  • 10,160
  • 7
  • 43
  • 68