Email is not getting sent to Office365 Email account

Does anyone know why my office365 email account works from inside our domain but does not work from our DMZ server?

Email sent from DMZ server to recipients with exchange account works fine.

However, users are not receiving emails sent to our office365 email account.

I have tried using my domain account but it does not work. I also tried using the DMZ server account but that does not send email either.

Any ideas?

    Protected Sub btnSubmit_Click(ByVal sender As Object, ByVal e As EventArgs) Handles btnSubmit.Click
        'Address of email sender
        Dim ccEmail As String = txtemail.Text

        'Create the msg object to be sent
        Dim msg As New MailMessage()

        'Add your email address to the recipients
        msg.[To].Add("office365emailaccount")
        'Configure the address we are sending the mail from
        Dim fromEmail As New MailAddress(ccEmail)
        msg.From = fromEmail
        'Append their name in the beginning of the subject
        msg.Subject = "Testing Office365 email account"

        'To embed image in email
        msg.Body = "If you receive this email, then office365 email account is working from DMZ server"
        '   msg.Attachments.Add(New Attachment(New MemoryStream(bytes), lblEmpName.Text & DateTime.Now.Ticks & ".pdf"))
        msg.IsBodyHtml = True

        'Configure an SmtpClient to send the mail.
        Dim client As New SmtpClient("xxx.xxx.x.xxx")   'Exhange IP Address
        client.Host = "smtp.office365.com"
        client.Credentials = New System.Net.NetworkCredential("dmzuser", "mydmzpassword")
        'client.DeliveryMethod = SmtpDeliveryMethod.Network
        client.EnableSsl = True
        client.Port = 25
        'Send the msg
        client.Send(msg)
        lblMsg.Text = "Success!"
    End Sub

Open in new window


Thanks in advance
LVL 29
sammySeltzerAsked:
Who is Participating?
 
Gaurav SinghSolution ArchitectCommented:
if you are using 0365 SMTP server in your script, it wont work, you need to create relay account in 0365

Refer http://office365support.ca/smtp-relay-with-office-365/
0
 
David Johnson, CD, MVPOwnerCommented:
check your exchange transport logs
0
 
sammySeltzerAuthor Commented:
Creating a relay on 0365 solved it for me.
Thanks
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.