Hi,

I am having trouble getting my clients website to send the form details to their email. Their email is not handled by their hosting but externally using Office 365.

I have tested the site forms and they send succeffully to a wide variety of test email accounts ALL except the Office365 email accounts. The sites IP address has been added to the emails white list. Ive tried using a SMTP plugin but still no joy.

Has anyone ever had this issue and know how to resolve it, I have ran out of ideas???

Hi Donna!

Try to whitelist the email address that is sending the mail from the website along with the IP, if this does not help, then it could be due to the IP reputation. If you think it can be Wordpress then try a separated script, for example through PHPMailer, once you have the library try this:

Just replace domain, credentials and the sender email address.

You should get a log of the telnet session, displaying the authentication process, the sending of the body and the result of the operation.

If it works successfully: it returns ok but you still don't get anything, then it's probably a filter on their side and, maybe, it's better to ask to Office365 support and see if they can add some details or solutions.

Hi Cereal. thanks for your reply :)

I should of mentioned previously the only way I can get form details to email to the client is by using a SMTP plugin configured to a gmail account. I tried setting the the smtp with their email settings but it fails to connect?

Is there any way of checking which end it is failing at?

Are you trying to connect through TLS or SSL port? At the moment I can only think to test PHPMailer to see the telnet session, the result should look like this:

2015-10-04 02:55:31 SERVER -> CLIENT: 220 smtp.gmail.com ESMTP RNDSTRNG.4 - gsmtp
2015-10-04 02:55:31 CLIENT -> SERVER: EHLO my_hostname
2015-10-04 02:55:31 SERVER -> CLIENT: 250-smtp.gmail.com at your service, [0.0.0.0]
                                      250-SIZE 35882577
                                      250-8BITMIME
                                      250-AUTH LOGIN PLAIN XOAUTH2 PLAIN-CLIENTTOKEN XOAUTH OAUTHBEARER
                                      250-ENHANCEDSTATUSCODES
                                      250-PIPELINING
                                      250-CHUNKING
                                      250 SMTPUTF8
2015-10-04 02:55:31 CLIENT -> SERVER: AUTH LOGIN
2015-10-04 02:55:31 SERVER -> CLIENT: 334 RNDMSTRNG
2015-10-04 02:55:31 CLIENT -> SERVER: RNDSTRNGFRMSRVR==
2015-10-04 02:55:31 SERVER -> CLIENT: 334 NTHRBT
2015-10-04 02:55:31 CLIENT -> SERVER: NTHNSWR==
2015-10-04 02:55:32 SERVER -> CLIENT: 235 2.7.0 Accepted
2015-10-04 02:55:32 CLIENT -> SERVER: MAIL FROM:<from@gmail.com>
2015-10-04 02:55:32 SERVER -> CLIENT: 250 2.1.0 OK RNDSTRNG.4 - gsmtp
2015-10-04 02:55:32 CLIENT -> SERVER: RCPT TO:<to@gmail.com>
2015-10-04 02:55:32 SERVER -> CLIENT: 250 2.1.5 OK RNDSTRNG.4 - gsmtp
2015-10-04 02:55:32 CLIENT -> SERVER: DATA
2015-10-04 02:55:32 SERVER -> CLIENT: 354  Go ahead RNDSTRNG.4 - gsmtp
2015-10-04 02:55:32 CLIENT -> SERVER: Date: Sun, 4 Oct 2015 04:55:31 +0200
2015-10-04 02:55:32 CLIENT -> SERVER: To: "Name" <to@gmail.com>
2015-10-04 02:55:32 CLIENT -> SERVER: From: Name <from@gmail.com>
2015-10-04 02:55:32 CLIENT -> SERVER: Subject: Test
2015-10-04 02:55:32 CLIENT -> SERVER: Message-ID: <RND1D@my_hostname>
2015-10-04 02:55:32 CLIENT -> SERVER: X-Priority: 3
2015-10-04 02:55:32 CLIENT -> SERVER: X-Mailer: PHPMailer 5.2.8 (https://github.com/PHPMailer/PHPMailer/)
2015-10-04 02:55:32 CLIENT -> SERVER: MIME-Version: 1.0
2015-10-04 02:55:32 CLIENT -> SERVER: Content-Type: text/plain; charset=iso-8859-1
2015-10-04 02:55:32 CLIENT -> SERVER: Content-Transfer-Encoding: 8bit
2015-10-04 02:55:32 CLIENT -> SERVER:
2015-10-04 02:55:32 CLIENT -> SERVER: Hello World
2015-10-04 02:55:32 CLIENT -> SERVER:
2015-10-04 02:55:32 CLIENT -> SERVER: .
2015-10-04 02:55:33 SERVER -> CLIENT: 250 2.0.0 OK 1443927333 RNDSTRNG.4 - gsmtp
2015-10-04 02:55:33 CLIENT -> SERVER: QUIT
2015-10-04 02:55:33 SERVER -> CLIENT: 221 2.0.0 closing connection RNDSTRNG.4 - gsmtp

The above example is a connection to a smtp.gmail.com, but when sending to smtp.office365.com you should see something similar or, at least, a message that explains why is failing: not connecting to port, refused by server or something else. Unfortunately, a part that, I don't have many other ideas.

Thank Cereal, Can you point me to any tutorials on how I go about setting up this type of
test?

I can write it for you, it's easy. You have to:

  • click the download link on the right side of this page:
    https://github.com/PHPMailer/PHPMailer
  • create a directory in your server and upload the uncompressed archive
  • then create this script:

    <?php
    
    require './PHPMailerAutoload.php';
    
    $mail = new PHPMailer;
    
    $mail->isSMTP();
    $mail->WordWrap    = 50;
    $mail->SMTPDebug   = 3;
    $mail->Debugoutput = 'html';
    $mail->SMTPAuth    = TRUE;
    
    # Office265 credentials
    $mail->Host        = 'tsl://smtp.office365.com:587;ssl://smtp.office365.com:995';
    $mail->Username    = 'username@domain.tld';
    $mail->Password    = 'password';
    
    # set FROM header
    $mail->From        = 'username@domain.tld';
    $mail->FromName    = 'website';
    
    # set TO header
    $mail->addAddress('recipient@domain.tld', 'Recipient Name');
    
    $mail->Subject     = 'Test';
    $mail->Body        = 'Hello World!';
    
    echo ! $mail->send() ? 'Error: ' . $mail->ErrorInfo : 'Success!';
    

and simply save the file to your server, remember to adjust the require call, in order to start autoload file.

Then load the above script from browser: with correct credentials you should see a log similar to my previous post, else you will see the errors. Note this line:

$mail->Host = 'tsl://smtp.office365.com:587;ssl://smtp.office365.com:995';

it is defining TSL or SSL connection which use different port numbers, these should be 587 and 995. The first line of the log, should tell you what is used, in my case it starts with SSL, while if I try only TSL it fails immediately.

The log should give you some information about what is going wrong: credentials, port numbers, IP and, if problem is on yours end, help you to fix Wordpress configuration.

If in doubt you can post the result here.

Thank you so much cereal I will give that a try.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.