电子邮件在本地工作但不在服务器上 [英] email working local but not on server

查看:145
本文介绍了电子邮件在本地工作但不在服务器上的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在按钮点击事件后发送电子邮件。当我从本地机器上测试时,一切运行顺畅,电子邮件发送出去,我收到弹出消息,通知我呼叫已经解决。但是从服务器端运行页面挂起 - 屏幕变暗,这应该发生,直到电子邮件被发送,但它保持这样。电子邮件不会从服务器端发出....



I'm trying to send out an email after a button click event. When testing from my local machine everything runs smooth, the email get send out and I get the popup message notifying me that the "call has been resolved". But running from server side the page "hangs" - the screen is dimmed out which should happen until the email is sent off, but it stays like that. the email does not get sent out from server side....

  MailMessage Mail = new MailMessage();
        Mail.Subject = "Call Resolved";
        Mail.To.Add(useremail);
        //  Mail.To.Add(useremail);
        Mail.From = new MailAddress("notifications@oep.co.za");

        string path = PopulateEmailImage();

        LinkedResource logo = new LinkedResource(path);
        logo.ContentId = "header";

        AlternateView av1 = AlternateView.CreateAlternateViewFromString("<html><head>" +
                            @"<meta content=""text/html; charset=utf-8"" http-equiv=""Content-Type""/> " +
                            @"<title></title></head><body ><style> " +
                        @".auto-style1 {width: 188px; }table tr td{ border:solid;border-width:1px;} .link{color:red;}</style> " +
                        @"<img alt="""" height=""130"" src=""cid:header"" width=""675"" /> " +
                        @"<div style=""color:red; font-weight:bold; text-align:left; border:none; margin-right:20%;"" > " +
                        @"<h3>This message is sent on behalf of <br /> The Business Connexion Global Service Management Centre</h3> " +
                        @"<h5>Please do not respond to the sender as this mailbox does not receive return mail. <br /> " +
                        @"Use the Link located at the bottom of the e-mail to Respond </h5> </div><br />" +
                        @"<div>Dear " + CustName + "</div><br /> " +
                        @"<div>We are pleased to inform you that your reported Incident " + incidentNo + ", has been resolved. </div><br /> " +
                        @"<div>Incident Summary report as follows:</div> <br /> " +
                        @"<table style=""width:45%; border:solid; border-width:3px; background-color:#E2E2E2;""> " +
                        @"<tr><td class=""auto-style1"">Incident Number:</td><td>" + incidentNo + "</td> " +
                        @"<tr><td class=""auto-style1"">Status:</td><td>" + stats + "</td></tr> " +
                        @"<tr><td class=""auto-style1"">CI Serial No:</td><td>" + serialNo + "</td></tr> " +
                        @"<tr><td class=""auto-style1"">Incident Summary:</td><td>" + incidentSum + "</td></tr> " +
                        @"<tr><td class=""auto-style1"">Incident Notes:</td><td>" + incidentNotes + "</td></tr> " +
                        @"<tr><td class=""auto-style1"">Resolution:</td><td>" + resolution + "</td></tr> " +
                        @"</table><br /><div> " +
                        @"If you have any queries or if you would like to change your contact details, please contact the <br /> Global Service Management Centre. " +
                        @"</div><br /><div> " +
                        @"<a href=""spoc@bcx.co.za"" class=""link"">Click here if you would like to contact the Global Service Management Centre via e-mail</a> </div> " +
                        @"<br /><div>011 266 1102 (National, South African number) <br />+27 (0) 266 1102 (International number)<br /> " +
                        @"E-mail queries to <a href=""spoc@bcx.co.za"" class=""link"">spoc@bcx.co.za</a> <br /></div><br /><div>Yours in service <br /> " +
                        @"Global Service Management Centre</div></body></html>", null, MediaTypeNames.Text.Html);

        av1.LinkedResources.Add(logo);
        Mail.AlternateViews.Add(av1);

        System.Configuration.Configuration configurationFile = WebConfigurationManager.OpenWebConfiguration("~/web.config");
        MailSettingsSectionGroup mailSettings = configurationFile.GetSectionGroup("system.net/mailSettings") as MailSettingsSectionGroup;
        if (mailSettings != null)
        {
            int port = mailSettings.Smtp.Network.Port;
            string host = mailSettings.Smtp.Network.Host;
            string password = mailSettings.Smtp.Network.Password;
            string username = mailSettings.Smtp.Network.UserName;
        }
        SmtpClient SMTP = new SmtpClient();
        SMTP.Send(Mail);

<mailSettings>
  <smtp deliveryMethod="Network" from="Notifications@office.co.za">
    <network host="ipAddress" userName="notifications@oep.co.za" password="password" port="25" />
  </smtp>
</mailSettings>





EnalbleSSl已设置为false且为true - 两者均无效。我用telnet来检查我是否可以连接到ip和端口 - 两者都很好......任何帮助都将不胜感激!没有防火墙阻止电子邮件发送。



The EnalbleSSl has been set to false and true - neither works. I have used telnet to check if I can connect to the ip and port - both is fine... Any help will be greatly appreciated! There are no firewalls that is blocking the email from sending out either.

推荐答案

在smtp.send请求期间添加try catch块可能会遇到异常
Add try catch block may be getting some exception during smtp.send request


这篇关于电子邮件在本地工作但不在服务器上的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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