Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problem sending text message through email 1

Status
Not open for further replies.

sjulian

Programmer
Aug 15, 2000
56
0
0
US
My Visual Basic 2010 application needs to send a text message to three phones under certain conditions.
Written and tested on a Win7 machine it works fine.
After installing on the production machine, a Win Server 2003, the following error occurs:
"5 Mailbox unavailable. The server response was: 5.7.1 <3175551212@messaging.sprintpcs.com>... Relaying denied in sbSendEmail" (number in address changed for security purposes)
Same error occurs when sending to a Verizon account.
If I substitute a standard email address, i.e. email@company.com the email goes through.
My "systems guy" assures me that there is nothing in the firewall that would block one email and not another. Could there be a OS setting that is affecting this?
Here is the block of code used to send the email:
Code:
Imports System.Net.Mail
Imports System.Net
 Private Sub sbSendEmail(ByVal msgText As String)
        Dim ErrMsg As String = ""
        Dim fEmail As Integer
        Dim strAddTemp As String = ""

        On Error GoTo sbsendemail_errortrap
        fEmail = FreeFile()
        FileOpen(fEmail, Application.StartupPath & "\emailaddresses.txt", OpenMode.Input)
        Dim smtpServer As New SmtpClient("mail.company.com")
        Dim mail As New MailMessage
        mail.From = New MailAddress("name@company.com")
        Do Until EOF(fEmail)
            Input(fEmail, strAddTemp)
            mail.To.Add(strAddTemp)
        Loop
        FileClose(fEmail)
        mail.Subject = "IMS db Problem"
        mail.Body = msgText
        mail.Priority = MailPriority.High
        smtpServer.Port = 25
        smtpServer.EnableSsl = False
        smtpServer.Credentials = New NetworkCredential("name@company.com", "password")
        smtpServer.Send(mail)
        sbLogEntry("Email Sent", msgText)
        On Error GoTo 0
        Exit Sub
sbsendemail_errortrap:
        ErrMsg = Err.Number & " " & Err.Description & " in sbSendEmail"
        sbLogEntry(ErrMsg, "")
        Resume Next
    End Sub
 
Most likely the server you are using to send the email is configured to allow your computer/account to relay messages to the outside world, and with the program running on a server now (presumably a different user account) the mail server is rejecting the permission to relay to the outside world.

As long as the server handles the domain it is not considered a relay, and it would accept it (which is why email@company.com goes through fine).

If this is indeed the case, your mail server needs to be configured to allow the server you are running your app on permission to relay and/or have your application specify credentials to the mail server.
 
Are you trying to send emails TO the @sprint address or trying to make it look like it's coming FROM the @sprint addrress?
You're probably going to have to live with the FROM address being some sort of "alerts@yourcompany.com"

Lodlaiden

You've got questions and source code. We want both!
Oh? That? That's not an important password. - IT Security Admin (pw on whiteboard)
 
Trying to send FROM a regular email TO the sprint and verizion addresses.
Made a workaround by sending message to address that uses Outlook and setting up auto forward.
Works, but I'd prefer do to it right.
 
It sounds as though you can email the sprint/verizon address from outlook regular without an error. Is that correct?
Can you email ANYONE outside the firewall (external mail) with the account you have set up for the code?

Lodlaiden


You've got questions and source code. We want both!
Oh? That? That's not an important password. - IT Security Admin (pw on whiteboard)
 
Had blinders on . . . just tried another outside email address (not a cell phone text) and it failed with the same error as the text messages.
 
Exactly - I've had this issue when trying to send emails.

My development machine worked fine, but another client failed.

Make sure that the code you are using is authenticating with the mail server as a user AUTHORIZED to relay.

OR

In the Exchange Management Console (we use 2010 so it may be different for you) under "Server Configuration" > "Hub Transport" > "Receive Connectors" make sure that the target machine is allowed to relay messages. For us we have created a Connector just for this purpose with only TLS Authentication and Externally Secured - specifying the IP addresses that are allowed to do this (preventing the outside world from relaying).
 
I showed this to my systems guy and he said it makes sense, but right now it isn't worth it to try to get our mail server administrators to make any changes. Since the workaround is working, we'll just leave it as is.
Thanks to Borvik and Qik3Coder!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top