是否可以通过 .net 应用程序从使用 smtp-relay 的服务器发送电子邮件。
我正在使用 app.config 来获取服务器 IP 前的实际值,以及电子邮件应该使用的 fromadress。
根据 IT 技术人员的说法,不需要授权的用户名和密码,因为它使用 smtp-relay。将要发送电子邮件的计算机位于有效计算机的 smtp-servers 列表中。
这真的可以吗,我不需要指定用户名/密码吗?
try
{
MailMessage mail = new MailMessage();
SmtpClient SmtpServer = new SmtpClient(_smtpserver);
mail.From = new MailAddress(_fromAdress);
mail.To.Add(_toAdress);
mail.Subject = _subject;
mail.Body = _body;
mail.Priority = MailPriority.High;
SmtpServer.Port = Convert.ToInt32(_port);
SmtpServer.Credentials = new System.Net.NetworkCredential(_authUsername, _authPassword);
SmtpServer.EnableSsl = true;
SmtpServer.Send(mail);
}
catch (Exception ex)
{
Console.WriteLine(ex.ToString());
}