Email sending works locally but not on remote server

Posted on

Question :

I have a problem sending email using a server I created in a contracted data center.

Sending e-mail works locally normally, although SMTP is in a well-known hosting company (I’ve seen that they allow 20 emails per day for international IP). I’ve tried using other email services and it always works locally.

$mail = new PHPMailer;
$mail->isSMTP();
$mail->Host = $host;
$mail->SMTPAuth = true;
$mail->Username = $user;
$mail->Password = $password;
$mail->Port = 587;
$mail->SMTPDebug  = 2; 
//$mail->SMTPSecure = 'tls';
$mail->From = $from_mail;
$mail->FromName = $from_name;
$mail->addAddress($to);

$mail->WordWrap = 50;                                 
$mail->isHTML(true);                               

$mail->Subject = $subject;
$mail->Body    = $message;

if(!$mail->send()) {
  echo 'Message could not be sent.';
  echo 'Mailer Error: ' . $mail->ErrorInfo;
  exit;
}

Does anyone have any idea what it can be?

The return whenever I try to send on the remote server is

  

2014-01-19 17:04:52 SMTP ERROR: Failed to connect to server:
  Connection timed out (110) SMTP connect () failed. Message could not be
  sent.Mailer Error: SMTP connect () failed.

    

Answer :

Your ISP is preventing SMTP on your server / hosting, open a support ticket, and ask about the release.

It is a common practice for hosting providers / servers to keep SMTP traffic locked to prevent clients from sending spam.

Some do not release such access into more basic plans, even on request.

    

Leave a Reply

Your email address will not be published. Required fields are marked *