Jump to content

[Solved] Cannot send email via Google/Outlook/Mailgun SMTP via PhpMailer


zekus
 Share

Recommended Posts

Hi Heliohost,

 

My username is Zekus.
I am using Tommy server.

 

I cannot send mail from Outlook/Gmail/Mailgun SMTP, which is working with my local WAMP.
 
This is the error I received.

 

2018-01-06 16:10:56 Connection: opening to smtp-mail.outlook.com:587, timeout=300, options=array()
2018-01-06 16:11:05 Connection failed. Error #2: stream_socket_client(): unable to connect to smtp-mail.outlook.com:587 (Network is unreachable) [/home/zekus/public_html/*****/SMTP.php line 325]
2018-01-06 16:11:05 SMTP ERROR: Failed to connect to server: Network is unreachable (101)

 

 
But when I commented "$mail->isSMTP();" from my php file, it is working but an email will be sent to Junk mail.
I did try both port 465 for SSL and 587 for TLS.

Here is my PhpMailer code.

 

<?php
namespace PHPMailer;
use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\SMTP;
use PHPMailer\PHPMailer\Exception;

 
require_once 'PHPMailer.php';
require_once 'SMTP.php';
require_once 'Exception.php';
 
$mail = new PHPMailer;
$mail->IsSMTP();

$mail->SMTPDebug = 0;
$mail->Host = 'smtp-mail.outlook.com';
$mail->Port = 587;
$mail->SMTPSecure = 'tls';
$mail->SMTPAuth = True;

$mail->CharSet = 'UTF-8';  
$mail->SMTPKeepAlive = true;
 
$mail->Username = "admin@job4dent.com";
$mail->Password = "*****";
 
$mail->setFrom('admin@job4dent.com', 'Job4Dent');
$mail->addAddress('job4dent@outlook.com', 'John Doe');
 
$mail->Subject = 'PHPMailer 6.0 Outlook SMTP test';
$mail->Body =
            "Hi,<br>
            This system is working perfectly.";
$mail->IsHTML(true);
$mail->AltBody = 'This is a plain-text message body';

 
if (!$mail->send()) {
    echo "Mailer Error: " . $mail->ErrorInfo;
} else {
    echo "Message sent!";
}

 

When I change Host to tommy.heliohost.org or change my username and password, my email can be sent

but with warning of fraud email that was not directly sent by Google/Outlook.

 

It can be tested via https://4dent.tk/cronSendMailClinicGMail.php

 

Many thanks,

Zekus

Edited by zekus
Link to comment
Share on other sites


# telnet smtp-mail.outlook.com 587
Trying 40.97.136.194...
Connected to smtp-mail.outlook.com.
Escape character is '^]'.
220 CY4PR15CA0002.outlook.office365.com Microsoft ESMTP MAIL Service ready at Tue, 9 Jan 2018 02:49:31 +0000
^]
telnet> quit
Connection closed.
Port 587 to outlook is open on Tommy.
Link to comment
Share on other sites

Things like SPF will probably be missing, which would explain the spam flags and blocks (the providers want to see a valid mail server when the look up the connecting party to reduce spam) . You can try creating the MX and related records manually (you'll need to go into cpanel and look in the MX editor and the DNS editor to see what the correct values are).

 

No guarantees it'll work though.

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
 Share

  • Similar Content

    • By gomgo
      Hi! I want to use my e-mail (gomgo@gomgo.heliohost.us) to send and receive e-mail, how do i login in the e-mail. i use Windows, so use Windows Live Mail is my option, but is impossible, windows live mail is actuatually discontinued and impossible to use, so i can't use it, i tried to send me the instructions, but i don't receive anythingh, i tried to use the webmail with roundcube and horde, but i get 500 Error, so i want to use the e-mail, what can i do?
       
      Thanks
       
       
      Edit: I'm in the Johnny's Server
    • By Computer Nerd Kev
      Hello,

      I've come to the conclusion that the non-SSL SMTP email port on Tommy doesn't actually work without SSL (aka TLS).

      The background is that some of my Email software is old and when Tommy was upgraded after the crash, the new encryption libraries were no longer compatible with my old software. I've been slowly working to get that software working with a newer OpenSSL library, and making do until then in various ways.

      I recently set up a new email account (using a unique password) for which security isn't very important, so I tried going unencrypted using the non-SSL port for SMTP (587 on Tommy). But it wouldn't work.

      Long story short, the email server software isn't providing any authentication methods to the client unless STARTTLS is used to enable encryption.

      Here I'm trying to connect without SSL:
       
      <-- 220-tommy.heliohost.org ESMTP Exim 4.92 #2 Sat, 25 Jul 2020 05:38:10 +0000 <-- 220-We do not authorize the use of this system to transport unsolicited, <-- 220 and/or bulk e-mail. --> EHLO heliohost.org <-- 250-tommy.heliohost.org Hello heliohost.org [1.136.169.170] <-- 250-SIZE 52428800 <-- 250-8BITMIME <-- 250-PIPELINING <-- 250-STARTTLS <-- 250 HELP --> QUIT <-- 221 tommy.heliohost.org closing connection msmtp: the server does not support authentication msmtp: could not send mail 


      Here's what it looks like talking unencrypted to another server where it does work properly (some info redacted):
       
       
      <-- 220 [SERVERNAME] ESMTP Postfix (Ubuntu) --> EHLO localhost <-- 250-[SERVERNAME] <-- 250-PIPELINING <-- 250-SIZE 10240000 <-- 250-VRFY <-- 250-ETRN <-- 250-STARTTLS <-- 250-AUTH PLAIN LOGIN <---- We don't get this on Tommy! <-- 250-ENHANCEDSTATUSCODES <-- 250-8BITMIME <-- 250-DSN <-- 250 SMTPUTF8 --> AUTH PLAIN [ENCODED PASSWORD] <---- It tells us that we can do this <-- 235 2.7.0 Authentication successful --> MAIL FROM:<[MY EMAIL ADDRESS]> --> RCPT TO:<[RECEIVER'S EMAIL ADDRESS]> --> DATA <-- 250 2.1.0 Ok <-- 250 2.1.5 Ok <-- 354 End data with <CR><LF>.<CR><LF> --> Date: Sat, 25 Jul 2020 15:14:05 +1000 [MESSAGE] --> . <-- 250 2.0.0 Ok: queued as 7C7FE3B25F1 --> QUIT <-- 221 2.0.0 Bye 


      Here I'm back with Tommy using another client where the SSL is new enough to work, and STARTTLS is enabled (this is still on the non-SSL port 587):
       
       
      * Connecting to SMTP server: mail.ombertech.com ... [17:02:20] SMTP< 220-tommy.heliohost.org ESMTP Exim 4.92 #2 Sat, 25 Jul 2020 06:56:29 +0000 [17:02:20] SMTP< 220-We do not authorize the use of this system to transport unsolicited, [17:02:20] SMTP< 220 and/or bulk e-mail. [17:02:20] ESMTP> EHLO The-Overheating-Giant [17:02:20] ESMTP< 250-tommy.heliohost.org Hello The-Overheating-Giant [1.136.166.92] [17:02:20] ESMTP< 250-SIZE 52428800 [17:02:20] ESMTP< 250-8BITMIME [17:02:20] ESMTP< 250-PIPELINING [17:02:20] ESMTP< 250-STARTTLS [17:02:20] ESMTP< 250 HELP [17:02:20] ESMTP> STARTTLS [17:02:21] ESMTP< 220 TLS go ahead * SSL certificate of mail.ombertech.com previously accepted [17:02:21] ESMTP> EHLO The-Overheating-Giant [17:02:21] ESMTP< 250-tommy.heliohost.org Hello The-Overheating-Giant [1.136.166.92] [17:02:21] ESMTP< 250-SIZE 52428800 [17:02:21] ESMTP< 250-8BITMIME [17:02:21] ESMTP< 250-PIPELINING [17:02:21] ESMTP< 250-AUTH PLAIN LOGIN <---- Now Tommy talks about AUTH, but only after STARTTLS has enabled TLS/SSL [17:02:22] ESMTP< 250 HELP [17:02:22] ESMTP> AUTH PLAIN ******** [17:02:22] ESMTP< 235 Authentication succeeded [17:02:22] SMTP> MAIL FROM:<[MY EMAIL ADDRESS]> [17:02:22] SMTP< 250 OK [17:02:22] SMTP> RCPT TO:<[RECEIVER'S EMAIL ADDRESS]> [17:02:22] SMTP< 250 Accepted [17:02:22] SMTP> DATA [17:02:23] SMTP< 354 Enter message, ending with "." on a line by itself [17:02:23] SMTP> . (EOM) [17:02:23] SMTP< 250 OK id=1jzE6i-000PnH-MD [17:02:23] SMTP> QUIT [17:02:24] SMTP< 221 tommy.heliohost.org closing connection 


      In that same client if I disable STARTTLS it fails like on the other system. Here though I can force it to attempt the AUTH command even though no AUTH methods are provided by the server, but the server won't accept that:
       
       
      * Connecting to SMTP server: mail.ombertech.com ... [16:31:38] SMTP< 220-tommy.heliohost.org ESMTP Exim 4.92 #2 Sat, 25 Jul 2020 06:25:47 +0000 [16:31:38] SMTP< 220-We do not authorize the use of this system to transport unsolicited, [16:31:38] SMTP< 220 and/or bulk e-mail. [16:31:38] ESMTP> EHLO The-Overheating-Giant [16:31:38] ESMTP< 250-tommy.heliohost.org Hello The-Overheating-Giant [1.136.169.176] [16:31:38] ESMTP< 250-SIZE 52428800 [16:31:38] ESMTP< 250-8BITMIME [16:31:38] ESMTP< 250-PIPELINING [16:31:38] ESMTP< 250-STARTTLS [16:31:38] ESMTP< 250 HELP [16:31:38] ESMTP> AUTH PLAIN ******** [16:31:38] ESMTP< 503 AUTH command used when not advertised <---- Tommy knows when I'm trying to cheat ** LibSylph-WARNING: [16:31:38] error occurred on SMTP session ** error occurred on SMTP session ** Sylpheed-WARNING: send: error: 503 AUTH command used when not advertised ** LibSylph-WARNING: [16:31:38] Error occurred while sending the message. ** Error occurred while sending the message.  
      The intended SSL Port 465 works fine, if the client's encryption library is new enough. Perhaps port 587 is actually supposed to only work with STARTTLS and therefore SSL, even though the CPanel info suggests differently. So if it's intentional I'll go away with my tail between my legs and try to wrestle my old systems into the modern encrypted world (which I'm working on anyway). If it's a mistake in Exim's configuration though, I'd be glad to see it fixed.
       
      PS. No my current ISP doesn't have an authentication-free SMTP server available to customers, which I could use for sending by using my Heliohost-hosted email address in the "From:" header.
    • By ansab
      I have created a new email id on my account. First time it worked fie and opened in browser without any error. I have also setup the id on my android device using blue mail app. But for the last two days i am getting a error on opening the mail id using https://johnny.heliohost.org:2096/ it logs in to mail client and the shows the following error
      on this link https://johnny.heliohost.org:2096/xxxxxxxxxxxxxx/3rdparty/roundcube/index.php
      I can successfully send and receive mails using my device but not on web mail.
      I have deleted and recreated the account but the problem remains same.
      Ps: My other two mail id's are working fine.
      Please help.
    • By vico
      Seems like Google is having issues with Drive, at least for Brazil.
      I'm trying to download the latest restream.io's OBS fork but since the binaries are hosted on Drive the downloads always chop at the middle (even using wget doesnt solve the problem).

      Anybody else over the world experiencing issues with Gdrive too?
    • By ansab
      Hi guys, i have some problem with SMTP setting on johnny server.
      I am hosting my domain devansab.com at infinityfree.net and i have set my MX record to johnny.heliohost.org.
      I am facing some problem with this, when i setup my email in Gmail app then all works fine, but if i use any other mobile app (Blue mail) or use it on my wordpress with same settings then it did not connect to server.
      I am using these settings
      Email : my email created in heliohost account
      Passowrd: correct password
      IMAP::
      Server: johnny.heliohost.org
      Port 993
      Security SSL/TSL
       
      Thankyou.
×
×
  • Create New...