本文介绍了Sendmail使用SMTP服务器...的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 29岁程序员,3月因学历无情被辞! 我只是尝试使用C#生成电子邮件,但是,我认为我使用了错误的SMTP服务器,因为Gmail出于某种原因超时。 Google邮件是否需要在发件人地址或某些身份验证机制上进行安全配置,因为这显然是一个垃圾邮件电子邮件示例? 你会建议什么? 试试 { MailMessage m = new MailMessage(); m.Subject =test; m.From = new MailAddress([email protected]); m.To.Add([email protected]); SmtpClient smtp = new SmtpClient(smtp.gmail.com); smtp.Send(m); } catch(Exception ex){Console.WriteLine(ex.Source); } 解决方案 我最近开发了一个代码作为网站联系页面的一部分,需要在这里发送电子邮件是代码。 var sender = contact.Email; var email = new MailMessage(); email.To.Add( new MailAddress( [email protected])); email.From = new MailAddress( [email protected]); email.Subject = form [ Tipo de contacto] + de + sender; email.Body = contact.Message; email.IsBodyHtml = true ; email.Priority = MailPriority.Normal; var smtp = new SmtpClient { Host = 192.168.145.209, Port = 25 , EnableSsl = false , UseDefaultCredentials = false , Credentials = new NetworkCredential( [email protected], lade I am just trying to generate an email using C#, however, I think I am using the wrong SMTP server, as Gmail times out for some reason. Is there some security configuration required by Google Mail on the From address, or some authentication mechanism that I need to go through, since this is obviously a 'spam' email example?What would you suggest?try { MailMessage m = new MailMessage(); m.Subject = "test"; m.From = new MailAddress("[email protected]"); m.To.Add("[email protected]"); SmtpClient smtp = new SmtpClient("smtp.gmail.com"); smtp.Send(m); } catch (Exception ex) { Console.WriteLine(ex.Source); } 解决方案 这篇关于Sendmail使用SMTP服务器...的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云!
08-01 23:16