×

Loading...
Ad by
  • 推荐 OXIO 加拿大高速网络,最低月费仅$40. 使用推荐码 RCR37MB 可获得一个月的免费服务
Ad by
  • 推荐 OXIO 加拿大高速网络,最低月费仅$40. 使用推荐码 RCR37MB 可获得一个月的免费服务

what I mean is you should do test before make conclusion:

what I would do is:

1. check network first.

do telnet GMAIL.SMTP.COM 25 ,

if you can't connect, then try

ping gmail.smtp.com.

in this case , you can clearly see gmail.smtp.com is not a valid domain, so I bet it wont even work in your home ( unless you have own hosts file or dns, which I doubt), so you must rememeber it wrong. Gmail should use its own domain, so smtp.gmail.com make more sense than gmail.smtp.com,

ping smtp.gmail.com , if you see a ip, then you get one step further. if not, you have dns problem.

telnet smtp.gmail.com 25, if you can not, since you can do it from home, then you have a firewall in your company.

If you can telnet to 25 port but still can't send email, then gmail might only allow authenticated user to send out email, then you should check something like Credentials as deep_blue mentioned. ( but then why "same" code work in your home? )
Report

Replies, comments and Discussions:

  • 工作学习 / 学科技术讨论 / Send email through ASP .NET?
    I created a ASP .NET application and used System.Net.Mail class to send email by connecting to GMAIL.SMTP.COM. Everything works fine at home, but when I ran same code at work place, it showed me the error "The connection was aborted by the host machine..."

    What's the cause? Is something related to firewall or SMTP config in IIS or other reasons?
    • Could someone help on this? Thanks.
    • It's probably that your machine has antivirus software.
    • typically, a corpoate network won't allow such a connection initiated from an internal box to an external wel-known service port (except port 80 or 443). It's the firewall, I guess...
    • 查web.config, 看authorization和impersonate. 根据具体情况, 或者增加ASP.NET帐户的权限, 或者改用windows authorization.
    • For security reason, most companies disable SMTP of local desktops. The emails are sent out from central mail server (via firewall system).
      You can ask your system admin about your mail server and try following: SmtpClientObj.Host = Mail Server IP (or Mail Server Name);

      You may also need to provide Credentials data for SmtpClient object like following:

      SmtpClientObj.Credentials = new System.Net.NetworkCredential(uid, password, domain);
    • funny so many people give you different solution and they all might be right, but the key issue they didn't say is how to troubleshoot it and find the real problem?
      in your case, what you need to do is start a cmd in your company machine, type in

      telnet gmail.smtp.com 25


      now you see you can't connect, and if you try
      telnet smtp.gmail.com 25

      you can connect.
      • telnet might not work
        telnet usally diabled these days.. i bet google did that too.
        • I bet you are wrong. Google didn't do that. You should do a test first:
          telnet SMTP.gmail.COM 25

          I am not saying you can connect for sure ( cause you might have your internal firewall), but google is open its port 25 ( of couse, to allow people use its smtp service.)
          • i just tried.. failed..Could not open connection to the host..
            • you are probably with rogers, which block port 25. you can check http://www.t1shopper.com/tools/port-scanner/
              put smtp.gmail.com and port 25 in, you can see it's responding.
      • Your method can't tell where the problem is.
    • what I mean is you should do test before make conclusion:
      what I would do is:

      1. check network first.

      do telnet GMAIL.SMTP.COM 25 ,

      if you can't connect, then try

      ping gmail.smtp.com.

      in this case , you can clearly see gmail.smtp.com is not a valid domain, so I bet it wont even work in your home ( unless you have own hosts file or dns, which I doubt), so you must rememeber it wrong. Gmail should use its own domain, so smtp.gmail.com make more sense than gmail.smtp.com,

      ping smtp.gmail.com , if you see a ip, then you get one step further. if not, you have dns problem.

      telnet smtp.gmail.com 25, if you can not, since you can do it from home, then you have a firewall in your company.

      If you can telnet to 25 port but still can't send email, then gmail might only allow authenticated user to send out email, then you should check something like Credentials as deep_blue mentioned. ( but then why "same" code work in your home? )
      • 纸上谈兵,自以为是。就没可能问题在server上? 比如 1: smtp service is down; 2: Anti-virus software blocks port 25.
        • yes, anything could go wrong, that's the reason you should check it step by step, not make guess in vain.
    • open port 587 on the firewall