简体   繁体   English

VB.NET GMAIL SMTP服务器设置

[英]VB.NET GMAIL SMTP Server Settings

I am using the Following Code for my GMAIL Server SMTP Settings, but am unable to send emails. 我将以下代码用于GMAIL服务器SMTP设置,但无法发送电子邮件。

Can anyone help me out... 谁能帮我吗...

        Dim emailClient As New SmtpClient("mail.gmail.com")
        Dim SMTPUserInfo As New System.Net.NetworkCredential("xxxxx@gmail.com", "abc123")

        emailClient.UseDefaultCredentials = False
        emailClient.Port = 465
        emailClient.EnableSsl = True
        emailClient.Credentials = SMTPUserInfo
        emailClient.Timeout = 1000000
        emailClient.Send(mail)

        emailClient = Nothing
        SMTPUserInfo = Nothing

     Catch ex As Exception
        MessageBox.Show(ex.Message & " Error Mails : ", Me.Text, MessageBoxButtons.OK)
    End Try

I think, you should use following settings: 我认为,您应该使用以下设置:

emailClient.Host = "smtp.gmail.com"
emailClient.port = 587
emailClient.EnableSsl = True

If you connect using SMTP, you can only send mail to Gmail or Google Apps users; 如果您使用SMTP进行连接,则只能将邮件发送给Gmail或Google Apps用户; if you connect using SSL/TLS, you can send mail to anyone. 如果使用SSL / TLS连接,则可以将邮件发送给任何人。 If your device or application supports SSL - connect to smtp.gmail.com on port 465. To connect with SSL, you need to provide a Google username and password for authentication. 如果您的设备或应用程序支持SSL,请通过端口465连接到smtp.gmail.com。要使用SSL连接,您需要提供Google用户名和密码进行身份验证。

Source: https://support.google.com/a/answer/176600?hl=en 来源: https//support.google.com/a/answer/176600?hl = zh_CN

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM