我正在使用vb2005进行开发,使用system.net.mail使用谷歌配置发送邮件。我的代码的完整示例是前面的posted here
With smtp
.Host = "smtp.google.com"
.Port = 465
.UseDefaultCredentials = False
.Credentials = New System.Net.NetworkCredential(mygoogleemail, mypass)
.EnableSsl = true
.Timeout = 60000
End With我知道操作已经超时了。如果我将端口更改为587,它会显示the server does not support secure connection
编辑防火墙会阻止它吗?
有没有指定发送应用程序名称的方法?
发布于 2011-03-14 00:28:31
试一试
Dim myLogin As New NetworkCredential("username@gmail.com", "password")
Dim msg As New MailMessage("username@gmail.com", "to@somedomain.com", "subjectLine", "emailBodyText")
msg.IsBodyHtml = True
Try
Dim client As New SmtpClient("smtp.gmail.com", 587)
client.EnableSsl = True
client.UseDefaultCredentials = false
client.Credentials = myLogin
client.Send(msg)
Catch ex As SmtpException
msgbox(ex.Message)
End Try如果超时,则进行故障排除
gmail credentials.
打开命令提示符,然后键入(不带引号) telnet smtp.gmail.com 25
如果你得到一个超时,那么问题要么是你的本地局域网阻止邮件或你的ISP。
发布于 2011-03-13 21:51:26
你有没有尝试过这个答案:Sending email through Gmail SMTP server with C#
只是想看看这招是否管用。
请注意,在他的解决方案的答案中,他提到了在帖子中较低的web.config更改不被接受为答案
<system.net>
<mailSettings>
<smtp from="myusername@gmail.com" deliveryMethod="Network">
<network defaultCredentials="false" enableSsl="true" host="smtp.gmail.com" port="587" password="password" userName="myusername@gmail.com"/>
</smtp>
</mailSettings>
</system.net>发布于 2011-03-14 00:15:05
操作中的端口是正确的,但主机错误
With smtp
.Port = 465 '465 for ssl
.EnableSsl = True
.UseDefaultCredentials = False
.Credentials = New System.Net.NetworkCredential("myusername@gmail.com", "yourpassword")
.Host = "smtp.gmail.com"
End With为了验证一下,你在gmail中启用了pop,对吗?
https://stackoverflow.com/questions/5289766
复制相似问题