通过在所有端口C#.NET错误的GMail SMTP [英] GMail SMTP via C# .Net errors on all ports

查看:522
本文介绍了通过在所有端口C#.NET错误的GMail SMTP的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直对这样的whlie,并且迄今已失败了。我最近尝试从这个堆栈code在这里举:<一href="http://stackoverflow.com/questions/704636/sending-email-through-gmail-smtp-server-with-c">http://stackoverflow.com/questions/704636/sending-email-through-gmail-smtp-server-with-c,但我已经尝试了所有的语法,我可以在这里找到的堆栈和其他地方。我的code当前是:

I've been trying for a whlie on this, and have so far been failing miserably. My most recent attempt was lifted from this stack code here: http://stackoverflow.com/questions/704636/sending-email-through-gmail-smtp-server-with-c, but I've tried all the syntax I could find here on stack and elsewhere. My code currently is:

var client = new SmtpClient("smtp.gmail.com", 587)
{
    Credentials = new NetworkCredential("me@gmail.com", "mypass"),
    EnableSsl = true
};

client.Send("me@gmail.com","me@gmail.com","Test", "test message");

运行code给我立即例外失败发送邮件,有一个innerexeption无法连接到远程服务器。

Running that code gives me an immediate exception "Failure sending mail" that has an innerexeption "unable to connect to the remote server".

如果我更改端口465(例如Gmail文档提示),我每次都获得超时。

If I change the port to 465 (as gmail docs suggest), I get a timeout every time.

我读过,465不是一个好的端口来使用,所以我不知道这笔交易是W / 587给我连接失败。我的用户和传球是正确的。我读过,我必须有POP服务安装在我的Gmail帐户,所以我做到了这一点。没有结果。

I've read that 465 isn't a good port to use, so I'm wondering what the deal is w/ 587 giving me failure to connect. My user and pass are right. I've read that I have to have POP service setup on my gmail account, so I did that. No avail.

我本来试图让这个工作对我的品牌的Gmail帐户,但在运行到同样的问题瓦特/我的认为的去瓦特/我的正常的Gmail帐户会更容易...所以远的情况并非如此。

I was originally trying to get this working for my branded GMail account, but after running into the same problems w/ that I thought going w/ my regular gmail account would be easier... so far that's not the case.

感谢您的帮助。 保

推荐答案

我想你的code,和它的作品prefectly与端口587,但不与465

I tried your code, and it works prefectly with port 587, but not with 465.

你检查的防火墙?在命令行的Telnet smtp.gmail.com 587尝试 如果你得到220 mx.google.com ESMTP ......后面的话,端口是开放的。如果不是,它是你调用块的东西。

Have you checked the fire wall? Try from the command line "Telnet smtp.gmail.com 587" If you get "220 mx.google.com ESMTP...." back, then the port is open. If not, it is something that blocks you call.

丹尼尔

这篇关于通过在所有端口C#.NET错误的GMail SMTP的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆