Locked Problems sending email to phones

  • 2012年3月29日 16:43
     
      コードあり

    Hi everyone.  I'm having a problem with some functionality that I added to a program 4 or 5 months ago.  It worked perfectly for the first couple of months, and then along with an update for Norton Internet Security, it stopped working, or would work sporadically.  Essentially, it takes some information and emails it to the phone number @ the mobile carrier's text message address like so as an example: 1235551212@vtext.com.

    I contacted Verizon about this when it stopped working and they said that it wasn't them and that there was no problem with doing it this way.

    I contacted Symantec, and was able to get my app on their White List, but that seemed to have rather random results.  Sometimes the text would arrive, other times it would not.  More often than not it wouldn't arrive.  Norton would not notify you of any blocked action or anything.

    So, at this point, I'm really at a loss.  This was a feature that everyone really liked, and I would like it to be reliable.  So, I'm posting my code and hoping that someone might be able to make a suggestion that would resolve this matter, or have an idea that would allow this to work.  I have no idea what else I can do here...

    Here is my code:

            string CarrierExtension = "";
            string TextString = "";
            private void ComposeText()
            {
                //Build Text Body
                TextString = "Customer: " + TName + " | ";
                if (CompanyCheck.Checked == true)
                {
                    TextString += TCompany + " | ";
                }
                if (HPhoneCheck.Checked == true)
                {
                    TextString += "H: " + THPhone + " | ";
                }
                if (WPhoneCheck.Checked == true)
                {
                    TextString += "W: " + TWPhone + " | ";
                }
                if (MPhoneCheck.Checked == true)
                {
                    TextString += "M: " + TMPhone + " | ";
                }
                if (OPhoneCheck.Checked == true)
                {
                    TextString += TOPhone + " - " + TOPhoneNote + " | ";
                }
                if (Address1Check.Checked == true)
                {
                    TextString += TAddress1 + " , ";
                }
                if (Address2Check.Checked == true)
                {
                    TextString += TAddress2 + " , ";
                }
                if (CityCheck.Checked == true)
                {
                    TextString += TCity + " | ";
                }
                if (BAddress1Check.Checked == true)
                {
                    TextString += TBAddress1 + " , ";
                }
                if (BAddress2Check.Checked == true)
                {
                    TextString += TBAddress2 + " , ";
                }
                if (BCityCheck.Checked == true)
                {
                    TextString += TBCity + " | ";
                }
                TextString += NoteTB.Text;
    
                CheckTextLength();
            }
    
            private void SendText()
            {
                try
                {
                    //Trim MobileString
                    StaffMobile = StaffMobile.Replace("(", "");
                    StaffMobile = StaffMobile.Replace(")", "");
                    StaffMobile = StaffMobile.Replace("-", "");
                    StaffMobile = StaffMobile.Replace(" ", "");
    
                    //Get Mobile Extension
                    if (StaffCarrier == "Alltel")
                    {
                        CarrierExtension = "@message.alltel.com";
                    }
                    if (StaffCarrier == "AT&T")
                    {
                        CarrierExtension = "@txt.att.net";
                    }
                    if (StaffCarrier == "Boost")
                    {
                        CarrierExtension = "@myboostmobile.com";
                    }
                    if (StaffCarrier == "Nextel")
                    {
                        CarrierExtension = "@messaging.nextel.com";
                    }
                    if (StaffCarrier == "Sprint")
                    {
                        CarrierExtension = "@messaging.sprintpcs.com";
                    }
                    if (StaffCarrier == "T-Mobile")
                    {
                        CarrierExtension = "@tmomail.net";
                    }
                    if (StaffCarrier == "TracFone")
                    {
                        CarrierExtension = "@mmst5.tracfone.com";
                    }
                    if (StaffCarrier == "US Cellular")
                    {
                        CarrierExtension = "@email.uscc.net";
                    }
                    if (StaffCarrier == "Verizon")
                    {
                        CarrierExtension = "@vtext.com";
                        //CarrierExtension = "@vzwpics.com";
                    }
                    if (StaffCarrier == "Virgin")
                    {
                        CarrierExtension = "@vmobl.com";
                    }
    
                    TextBW1.RunWorkerAsync();
                }
    
            }
    
            private void TextBW1_DoWork(object sender, DoWorkEventArgs e)
            {
                try
                {
                    MailMessage TextMessage = new MailMessage("Text@mymail.com", StaffMobile + CarrierExtension);
    
                    //Set the property of the message body and subject body
                    TextMessage.Body = TextString;
                    TextMessage.Subject = "";
    
                    //E-Mail Credentials and Sending
                    SmtpClient TextClient = new SmtpClient("smtp.1and1.com");
                    TextClient.Port = 587;
                    //TextClient.Port = 25;
                    System.Net.NetworkCredential TextCredential = new
                    System.Net.NetworkCredential("Text@mymail.com", "mypassword");
                    TextClient.Credentials = TextCredential;
                    TextClient.Send(TextMessage);
                }
                catch (System.Exception Mailex)
                {
                    //MessageBox.Show("An unexpected error occured. " + Mailex.ToString());
                    DSave form = new DSave("TextFailed", UserID + " " + UserFName + " " + UserLName, this.Name + ": " + this.Text, Mailex, "5");
                    form.ShowDialog();
                }
            }
    
            private void TextBW1_ProgressChanged(object sender, ProgressChangedEventArgs e)
            {
    
            }
    
            private void TextBW1_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
            {
                DSave form = new DSave("Sent");
                form.ShowDialog();
    
                InsertTextRecord();
            }

    Thanks Again,

    -Matt-

    • 移動 Leo Liu - MSFT 2012年4月2日 9:58 Moved for better support. (From:Visual C# Express Edition)
    •  

すべての返信

  • 2012年4月2日 10:00
     
     
    Hi Matt,

    I am moving your thread into the  Network Class Library (System.Net) Forum for dedicated support.
    Have a nice day,

    Leo Liu [MSFT]
    MSDN Community Support | Feedback to us

  • 2012年4月5日 3:58
     
     

    I think you could delicate a different SMTP server (by adding SMTP server feature on that server), and then disable email scanning on both your web server and that SMTP server (could be the same server). (You may also need to amend the SPF record of your company's DNS record if your company uses it.)

    If there's still emails being blocked, consider take a look at your corporate firewall to see if there's additional email filtering... (Certain mid-to-high rank hardware firewall models from vendors such as SonicWall have this feature. Read the manual to see what can be done on this case.)

    That should evade blocking of Symantec from your side, now you cross your finger and hope it won't be blocked on the remote side... (they most probably wouldn't, but you never know unless you try...)

    Split the queue according to StaffCarrier to avoid sending to many emails concurrently to single domain at once may help in some case. In my experience, sending 30 email to single domain on single connection is pretty safe bet (Note on Microsoft's SMTP server, I think only the one installed with Exchange offer this kind of configuration. Didn't tried to configure that on Win2008 or later, so you may still want to take a look).

    • 編集済み cheong00 2012年4月5日 4:03
    •  
  • 2012年4月8日 5:09
     
     

    I think you should be patient first, so as to clearly understand the symptoms further.

    I think your code is fine. As this feature does not work recently, do you know whether this email you send from code lands on the following devices (SMTP server, ISP services)? If not, where does it get lost? Without knowning this, I think it is hard to find a solution.

    My suggestion is,

    1. Find a machine that you can reproduce this issue constantly.

    2. Install Microsoft Network Monitor or Wireshark on it to monitor outgoing packets.

    When the problem happens again, check if the SMTP packets go out successfully. If they go out properly, then the client side is clear, and you can move on to next stop, aka the SMTP server you set in code.

    Not sure if that SMTP is fully managed by you. If it is, then you can also utilize Network Monitor (running netmon on both the client and the server). If not, require assistance from the administrators from that server.

    Hope following such an approach you can locate the culprit.

    Regards,


    Lex Li (http://lextm.com)

  • 2012年4月9日 20:25
     
     

    Thank you very much.  I'm taking everyone's suggestions and looking into this further.  I will post back as soon as I can.  I'm going to try to play around with what precisely is occurring.  I don't believe it's the SMTP server (Which is run by 1and1), as all of our other email and everything works without a problem.  I tried changing the address the mail is going to from [Number]@vtext.com to [Number]@vpix.com which Verizon uses for multimedia messages.  This didn't work.  I genuinely think that for some reason Norton is blocking these messages, but after working with Symantec and having my app added to the white list, it still occurs (And appears to reoccur with each new update).  So, that doesn't do the trick...  And it worked flawlessly until an update to Norton.  And from there, I'm out of ideas as to sending these messages.  It appears from reading that in order to send an SMS message, I have to contract with a company that does that and pay a fee for each message, which really isn't feasible...  After all, all I want to be able to do is send some information to phones when needed...

    I will definitely play around with this some more and post back.  I just for the life of me can't figure out what the problem is...

    Thanks Again,

    -Matt-

  • 2012年4月11日 5:09
     
     

    See if the probelm still occurs when you change the port number

    TextClient.Port = 587;    Reserved for SMTP

    There are "Well Known" (reserved)  port number and unreserved port numbers.  when you specify one of the reserved port number the message is only sent on that port number unless you add to your code a negotiation to retry a different TCP port number if the one you slected is already used.  A simple test if this is happening is to choose one of the many unreserved port number and see if you still have the problem.

    See webpage below

    http://en.wikipedia.org/wiki/List_of_TCP_and_UDP_port_numbers

    The webpage says the following : On Unix-like operating systems, a process must execute with superuser privileges to be able to bind a network socket to an IP address using one of the well-known ports

    Here are some reasons you could be having problems.

    1) If the mail server is a unix operating system you may have problems with priveldges

    2) Also if the port is busy you may have problems.

    3) Yo may want to change the time out of the TCP connection to -1 (infinity).  I don't recommend this, but only as a test.  Lots of people have problems with TCP when the connection goes down.  If you always get the first mail message to work, and then have random results with subsequent messages chagning the timeout to -1 will help determine the cause of the problem.

     


    jdweng

  • 2012年4月11日 5:24
     
     

    ......

    If there's problem with SMTP port binding, MLyons10 will not have any success case at all, and the emails of his company will have stopped function.

    Also, he already said that the SMTP server is operated by another vendor. So if there's really any problem with port binding, he would not have any right to fix/rearrange it...

  • 2012年7月18日 14:25
     
     回答済み
    I just wanted to post back in case someone else might be having a similar problem.  My issue was the result of Norton AntiVirus blocking the e-mails.  I was able to get my application approved for their white list and now all is fine.  :)
    • 回答としてマーク MLyons10 2012年7月18日 14:25
    •