通过电子邮件发送monodevelop .vs。 VS2013

时间:2014-01-23 22:34:04

标签: mono

我正在尝试在更大的流程运行完成后通过电子邮件发送一份小报告。电子邮件代码在VS2013的Windows 8.1下运行正常,但是当我在Ubuntu(13.10)下将代码移到单声道时,它会出错 -

ERROR 535 5.7.8 Error: Authentication failed: UGFzc3dvcmQ6 

- 令我感到困惑的是,如果在ubuntu / linux下存在身份验证失败,则不应在Windows 8.1下发生相同的身份验证失败。电子邮件服务器是我公司运行的服务器(不是gmail.com/live.com/etc)。任何帮助都会很棒,提前谢谢。

using System; 
using System.Collections.Generic; 
using System.Linq; 
using System.Text; 
using System.Threading.Tasks; 

using System.Net.Mail; 
using System.Net; 
using System.Security.Cryptography.X509Certificates; 
using System.Net.Security; 

using S22.Imap; 
using S22; 

namespace testing_email { 
    class Program {
        static void Main(string[] args) {
            SmtpClient client = new SmtpClient("mail.XXXXXX.com"); 

            client.DeliveryMethod = SmtpDeliveryMethod.Network; 
            client.UseDefaultCredentials = false; 
            client.Credentials = new System.Net.NetworkCredential("myreportuser@XXXXX.com", "password"); 
            client.Port = 25; 
            client.EnableSsl = true; 

            MailMessage mailit = new MailMessage(); 
            mailit.Body = "Body body body"; 
            mailit.Subject = "Testing Subject"; 
            mailit.IsBodyHtml = true; 
            mailit.From = new MailAddress("myreportuser@XXXXXX.com"); 
            mailit.To.Add("l.send.it@XXXXX.com"); 

            try {
                ServicePointManager.ServerCertificateValidationCallback = delegate(object s, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors) { return true; }; 

                client.Send(mailit); 
                Console.WriteLine("Message sent"); 
                Console.ReadLine(); 
            }
            catch (Exception ex) {
                Console.WriteLine("ERROR " + ex.Message); 
                Console.ReadLine(); 
            }
        }
    }
}

0 个答案:

没有答案