简体   繁体   English

无法发送邮件(邮件中继错误),在SMTP邮件服务器中具有所有设置

[英]Unable to send mail (Mail Relay error), have all settings in SMTP Mail Server

I have done all the setting, I tried hit and trial, specified IP etc but still I am unable to send mail from my c# code (outside my domain, within its fine). 我已完成所有设置,尝试了命中和试用,指定了IP等,但仍然无法从c#代码发送邮件(在我的域外,在其正常范围内)。

If I try to send mail by specifying credentials in web config, then I am able to send mails outside my domain. 如果我尝试通过在Web配置中指定凭据来发送邮件,则可以在我的域外发送邮件。 But that is not I want. 但这不是我想要的。

When I try to send via my code, then I do the setting on the SMTP , allow relay and specify domain, that doesn't work. 当我尝试通过代码发送时,然后在SMTP上进行设置,允许中继并指定域,这是行不通的。

I check the checkbox, which states that send mail to all address etc. That is also not working. 我选中该复选框,该复选框指出会将邮件发送到所有地址等。这也不起作用。

Where I am wrong? 我哪里错了?

My code: 我的代码:

When I specify in web config: 当我在Web配置中指定时:

<system.net>
<mailSettings>
  <smtp deliveryMethod="Network" from="abc@..com">
    <network enableSsl="false" host="hostname" port="25" userName="abc" password="abc#" defaultCredentials="false" clientDomain="domainname"/>
  </smtp>
</mailSettings>

When specifying through code: 通过代码指定时:

using (smtp)
{
smtp.Host = "hostname";
smtp.UseDefaultCredentials = false;
smtp.Port = 25;
smtp.EnableSsl = true;
smtp.Credentials = new System.Net.NetworkCredential("abc@newgen.co.in", "abc123#");
smtp.DeliveryMethod = SmtpDeliveryMethod.Network;
}

These settings in the server, but no success. 这些设置在服务器上,但是没有成功。 在此处输入图片说明

If you do not want to have credentials in your configuration file, then you have to enable relay access in the SMTP service for the IP address instead. 如果您不想在配置文件中拥有凭据,则必须在SMTP服务中为IP地址启用中继访问。 According to your screenshot, only authenticated connections are allowed to be relayed. 根据您的屏幕截图,仅允许中继经过身份验证的连接。

It usually helps to enable logging on the SMTP service so you can see exactly from where and how clients are trying to use the SMTP service. 通常,它有助于启用SMTP服务的登录功能,因此您可以准确地查看客户端尝试使用SMTP服务的位置和方式。

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

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