I´m trying to send a pair of mails through my app.
I´m using PHPMailer to do that
This is my code
- class SendMail{
- protected $mail;
- public function __construct(){
- $this->mail = new PHPMailer( true );
- $this->mail->isSMTP();
- $this->mail->setFrom('messanger@mydomain.com', 'MEssanger');
- $this->mail->SMTPDebug = 4;
- $this->mail->Host = 'smtp.zoho.com';
- $this->mail->SMTPAuth = true;
- $this->mail->Username = 'messanger@mydomain.com';
- $this->mail->Password = 'password;
- $this->mail->SMTPSecure = 'TLS';
- $this->mail->Port = 587;
- }
- public function sendMail( $title, $to, $name, $body ){
- $this->mail->addAddress($to, $name);
- $this->mail->isHTML(true);
- $this->mail->Subject = $title;
- $this->mail->Body = $body;
- return $this->mail->send();
- }
- }
Then i got an error
- 2018-11-22 21:29:51 Connection: opening to smtp.zoho.com:587, timeout=300, options=array()
- 2018-11-22 21:29:53 Connection failed. Error #2: stream_socket_client(): unable to connect to smtp.zoho.com:587 (Connection refused) [fakepath/SMTP.php line 326]<br>
- 2018-11-22 21:29:53 SMTP ERROR: Failed to connect to server: Connection refused (111)
- SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting
How could I solve it? Is a problem with zoho? misconfiguration?