Tech Off Thread

8 posts

Forum Read Only

This forum has been made read only by the site admins. No new threads or comments can be added.

Sending e-mail using Network Solutions from .Net code

Back to Forum: Tech Off
  • User profile image
    qwert231

    Many gripes today. #1 on my list, my IT guy, who spent the night wiping out our Active Directory all over the network and then decides to switch our e-mail provider without warning.

    K, not your problem.

    We were using Exchange, hosted on the webserver, to send out notification e-mails when an order was placed. Here is the code:
    Private Sub SendMail(ByVal from As String, ByVal toAddress As String, ByVal subject As String, ByVal body As String)
      Dim errMail As New System.Web.Mail.MailMessage
      Try
       With errMail
        .From = from
        .To = toAddress
        .Subject = subject
        .Body = body
        .BodyFormat = System.Web.Mail.MailFormat.Html
        '.Fields("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1
        '.Fields("http://schemas.microsoft.com/cdo/configuration/sendusername") = "***@centurycolor.com"
        '.Fields("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "******"
       End With
       System.Web.Mail.SmtpMail.SmtpServer = "mail.centurycolor.com"

       System.Web.Mail.SmtpMail.Send(errMail)
      Catch ex As Exception
       Throw New ApplicationException(ex.ToString)
      End Try
     End Sub

    I've tried with the .Fields commented and uncommented. Our pop3 is still mail.centurycolor.com. Our new e-mail provider is Network Solutions, they have no help how to get my code to send the e-mail. What I get for an error is this:
    System.Web.HttpException: The server rejected one or more recipient addresses. The server response was: 553 sorry, that domain isn't in my list of allowed rcpthosts (#5.7.1)

    The e-mail I'm sending to, mark@centurycolor.com, is alive and well. I'm assuming the cdo object won't work. What can I do, please, this is critical for us. (I can't believe he did that to me!!!PerplexedExpressionless)

  • User profile image
    Minh

    When doing email, I had to turn "Relay Restrictions" on the SMTP server. Not sure if that's your problem since it's a common problem & Network Solutions should be aware of that, but you never know...

  • User profile image
    Maurits

    In addition to a "POP3" server they should have given you an "SMTP" server.  If it's the same server then that's not the problem.

    If they just got you set up it's possible their mail server isn't configured yet.

    The error you're getting sounds like it's some kind of a problem where your .Net machine isn't on a list of allowed servers.  You may need to give Network Solutions the IP for that server.

    Or just install the Microsoft SMTP server on the .Net machine and dump it to the local queue - any machine can send mail.

  • User profile image
    blowdart

    Minh wrote:
    When doing email, I had to turn "Relay Restrictions" on the SMTP server. Not sure if that's your problem since it's a common problem & Network Solutions should be aware of that, but you never know...


    It does read like the QMail "I'm not relaying for you" message.

    Best of all it doesn't look like Network Solutions provideds an outgoing service; I went reading and found the manual setup page; you'll note how it says to use your ISP's outgoing SMTP server.

    Now if it's an actual full install of exchange on the web server then why bother with relaying, send direct. Heck, setup the SMTP service that comes with IIS and do that. Unless you're in a grubby ip range of course

  • User profile image
    qwert231

    Well... I'm more of a coder than an IT guy, and our IT guy figures it's my deal, so I'm stuck with it. K, for outgoing it is simple enough to set up SMTP on IIS 6. (The webserver is 2003). Any security holes w/ that? Anything I should be warned about?

    K, looking at this I have questions.

    1) I don't want my server to become a relay station, how to I make sure it doesn't.

    2) What do I need to change in my code, if anything to make it work.

  • User profile image
    Maurits

    qwert231 wrote:
    1) I don't want my server to become a relay station, how to I make sure it doesn't.


    If port 25 is firewalled off from the outside that is sufficient.  Otherwise you could configure the SMTP virtual server (in Internet Services Manager) only to accept email from 127.0.0.1 (the localhost IP)

    qwert231 wrote:

    2) What do I need to change in my code, if anything to make it work.


    Take out this line:
    System.Web.Mail.SmtpMail.SmtpServer = "mail.centurycolor.com"

    EDIT: And these (or leave them commented)
    '.Fields("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1
        '.Fields("http://schemas.microsoft.com/cdo/configuration/sendusername") = "***@centurycolor.com"
        '.Fields("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "******"

  • User profile image
    Mike Dimmick

    You can interpret mail server error codes using RFC 3463. 5.7.1 simply means that the message was rejected. I got a few of these errors yesterday when moving a program from my PC (part of the domain) across to the production server (not part of the domain), and had to configure our SMTP server to allow relaying from that server as well as allowing authenticated users to relay.

    Generally you should send out messages using your regular ISP - the one from whom you get your internet connectivity. These days, to reduce spam, ISPs normally only permit mail to come from an address within their range of allocated IP addresses. Some may permit authenticated email to come from outside. I'm not sure how to get System.Web.Mail to do authentication.

    I don't really know the standard Windows SMTP server that well; we have Exchange Server 2003 on Windows Server 2003. Exchange adds various plugins to the Windows SMTP server, and you administer that through the Exchange System Manager console.

  • User profile image
    qwert231

    We were using Exchange 5.5 on Windows 2k, which was the reason we switched and are now having e-mail hosted offsite. As for smtp authentication, those .Fields I had commented out were used when we had Exchange and it was requiring authentication.

    I did what Mauritis suggested, turning on SMTP on the web server, allowing only 127.0.0.1 to send mail, and it works. Thank you all for your help. This has broadened my horizons.

Conversation locked

This conversation has been locked by the site admins. No new comments can be made.