Send email with PHP (phpmailer) through Office365 to Hostgator

I want to send messages to Hostgator through office365. I was able to do this using gmail, but I can’t configure it to work with office365.

It works on my two other servers, which I have are just wonderful. The only problem is Hostgator. Do they need to take any action?

<?php require_once('class.phpmailer.php'); $mail = new PHPMailer(true); $mail->IsSMTP(); $mail->SMTPDebug = 2; $mail->SMTPAuth = true; $mail->SMTPSecure = "tls"; $mail->Host = "pod51014.outlook.com"; $mail->Port = 587; $mail->Username = "usernamehere"; $mail->Password = "************"; /* ... addaddres, reply, subject, message -> the usual stuff you need ... */ $mail->Send(); ?> 

I just keep answering like this:

 SMTP -> ERROR: Failed to connect to server: Connection refused (111) 

I was in a support chat with them, and port 587 should be open.

+7
source share
3 answers

I think hostgator blocks outgoing emails but accepts incoming emails.

0
source

If your hosting provider does not allow outgoing SMTP mail, I suggest you take a look at Microsoft Graph - the REST API, which also allows you to send emails and do much more. You can use, for example, the oauth2-azure library to interact with it very easily from your PHP code.

0
source

Try these things. Maybe something will work.

Ask the host:

 $mail->Host = 'smtp.office365.com'; 

Do not install the port at all:

 //$mail->Port = 587; 
0
source

All Articles