如何仅使用IP地址发送邮件 [英] How Do I Send Mail Using Only Ip Address

查看:278
本文介绍了如何仅使用IP地址发送邮件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Hello House,



我正在处理需要发送邮件通知的项目,smtp服务器要求使用ip指定from地址,我已经完成了这和它工作,但要部署应用程序,我只给了一个IP地址,我试过发送只有IP地址的邮件,但它不工作,错误信息是:没有连接,因为目标机器主动拒绝它10.90.17.203:25



i怀疑邮件服务器需要某种身份验证,客户端坚持认为他只向其他供应商提供ip,而且他们有能够用它发送邮件。如果可以的话,我需要你的帮助。这是我的代码:



Hello House,

I am working on project that requires sending mail notifications, the smtp server requires that the from address be specified with the ip, i have done this and it is working, but going to deploy the application, i am only given an ip address, i have tried sending mails with only ip address but it is not working, the error message is: No connection could be made because the target machine actively refused it 10.90.17.203:25

i suspect the mail server requires some sort of authentication, the client insists that he gives only the ip to other vendors, and they have been able to send mail with it. Please i need your assistance, if this could be done. here is my code:

static void CreateMail(string recipient, string subject, string msg)
        {
            Configuration oConfig = ConfigurationManager.OpenExeConfiguration( ConfigurationUserLevel.None );
            var mailSettings = oConfig.GetSectionGroup( "system.net/mailSettings" ) as MailSettingsSectionGroup;
            //var mailAttachment = (System.Configuration.ConfigurationManager.AppSettings["MailAttachment"]);
            var mailRecipients = ( ConfigurationManager.AppSettings["MailRecipients"] );

            if (mailSettings != null)
            {
                //int port = mailSettings.Smtp.Network.Port;
                var from = mailSettings.Smtp.From;
                var host = mailSettings.Smtp.Network.Host;
                var pwd = mailSettings.Smtp.Network.Password;
                var uid = mailSettings.Smtp.Network.UserName;

                try
                {
                    var message = new MailMessage();
                    message.To.Add(recipient);
                    message.Subject = subject;
                    message.From = new MailAddress(from);
                    message.Body = msg;
                   // message.Bcc =bcc;
                    message.Priority = MailPriority.Normal;

                   
                    var smtp = new SmtpClient(host);
                    smtp.Credentials = new System.Net.NetworkCredential(uid, pwd);
                    smtp.Send(message);
                    smtp.Dispose();
                    Log.Info("Mail sent successfully to the following recipients: " + "\n\r\n\r " + mailRecipients);
                    //}
                }
                catch (SmtpException ep)
                {
                    Log.Error(ep.ToString() + "\n\n\r " + ep.StackTrace);
                }

            }





我的配置文件:





My Config file:

<system.net>
    <mailSettings>
      <smtp from="mpeter@iqs-solutions.com">
        <network host="192.168.0.100" userName="mpeter@iqs-solutions.com" password="Sirpic.80"/>
      </smtp>
    </mailSettings>
  </system.net>

推荐答案

http://www.c-sharpcorner.com/Blogs/11147/send- email-in-As-Net-by-your-ip-without-email-id-and-passwo.aspx [ ^ ]







请尝试以上链接。阅读链接中的注释以便使用它。
http://www.c-sharpcorner.com/Blogs/11147/send-email-in-Asp-Net-by-your-ip-without-email-id-and-passwo.aspx[^]



Try the above link. Read the comments as well in the link to make use of it.


无法建立连接,因为目标机器主动拒绝它127.0.0.1:25 [ ^ ]



无法建立连接,因为目标计算机主动拒绝了它127.0.0.1: 25 [ ^ ]



http://stackoverflow.com/questions/9695224/no-connection-could-be-made-because-the-target-机器主动拒绝它-127-0 [ ^ ]



http://social.msdn.microsoft.com/forums/en-US/e425f1da-c92b-4a7a-84c7-1aac6493fc15/no-connection-could-be-made-because-the-target-machine -actively-refused-it-2002 [ ^ ]



请仔细阅读这些链接。它可以提供你的想法。
No connection could be made because the target machine actively refused it 127.0.0.1:25[^]

No connection could be made because the target machine actively refused it 127.0.0.1:25[^]

http://stackoverflow.com/questions/9695224/no-connection-could-be-made-because-the-target-machine-actively-refused-it-127-0[^]

http://social.msdn.microsoft.com/forums/en-US/e425f1da-c92b-4a7a-84c7-1aac6493fc15/no-connection-could-be-made-because-the-target-machine-actively-refused-it-2002[^]

Please go through these links.It can give u clr idea.


这篇关于如何仅使用IP地址发送邮件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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