无法通过C#中的WindowsService发送电子邮件 [英] cant send an email through WindowsService in C#

查看:86
本文介绍了无法通过C#中的WindowsService发送电子邮件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

WindowsService C#中,我正在尝试通过服务发送电子邮件,但出现错误消息,表明无法连接到远程服务器"并且发送失败.我尝试使用不同的帐户类型,例如本地服务,本地系统,网络和用户,但问题未解决,并且我也退出了Windows防火墙设置,组策略但问题仍然存在.请帮帮我.

In WindowsService C#, I''m trying to send email through service but it is giving an error saying that "unable to connect to the remote server" and sending failed. I tried with the different account types such as local service, local system, network and user but issue didnt resolved, and i also truned off windows fire wall settings,group policy but still issue remains the same. please help me out .

try
{
  var client = new SmtpClient(smtp.gmail.com,587)
  {
      EnableSsl = true,
      Credentials = new NetworkCredential(mamise@gmail.com,passwd)
  }; 
  client.Send(rprise@gmail.com,girish@gmail.com,Test,Test);
}

推荐答案

验证您用于连接Gmail的凭据是否正确.如果正确,请验证用于发送外发邮件的端口号.我不确定端口号是否为587.如果一切正确,但仍然无法发送邮件,请尝试使用已有的配置在Outlook上配置gmail帐户,然后尝试发送邮件.
Verify that the credentials you are using to connect Gmail is correct. If it is correct then verify the port no for sending outgoing mails. I am not sure if the port no is 587. If you got everything correct and still not being able to send mail then try configuring the gmail account on outlook using the configurations you have and try sending mail.


您也可以尝试检查其支持页面.您可能还需要执行一些故障排除步骤.
You can also try checking their support page. There''s also some troubleshooting steps that you may want to do.
来自页面:


如果您尝试在端口465(带有SSL)和端口587(带有TLS)上配置SMTP服务器,但是仍然无法发送邮件,请尝试将SMTP配置为使用端口25(带有SSL).


If you tried configuring your SMTP server on port 465 (with SSL) and port 587 (with TLS), but are still having trouble sending mail, try configuring your SMTP to use port 25 (with SSL).


https://support.google.com/mail/answer/78775?hl=zh_CN [ ^ ]


https://support.google.com/mail/answer/78775?hl=en[^]


这篇关于无法通过C#中的WindowsService发送电子邮件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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