Skip to main content
 首页 » 编程设计

c#之无法从 gmail 中的雅虎服务器发送电子邮件正在工作

2024年01月25日33exmyth

为了发送电子邮件,我设置了服务器名称 smtp.mail.yahoo.com 并且端口是 465 我尝试发送电子邮件但未能发送电子邮件

使用 yahoo 发送电子邮件的正确服务器名和 smtp 端口是什么

我还需要设置哪些其他配置?

我的代码在这里:

  System.Net.Mail.MailMessage message = new System.Net.Mail.MailMessage(); 
 
 
                message.To.Add(address); 
                message.Subject = subject; 
                message.From = new System.Net.Mail.MailAddress(from); 
                message.Body = body; 
                message.Bcc.Add(bcc); 
                message.CC.Add(cc); 
                System.Net.Mail.SmtpClient smtp = new System.Net.Mail.SmtpClient("smtp.mail.yahoo.com"); 
                smtp.Credentials = new System.Net.NetworkCredential(emailid,password); 
                smtp.Port = 465; 
                smtp.EnableSsl = true; 
                smtp.Send(message); 

请您参考如下方法:

我刚试过代码,我认为雅虎邮件服务器不使用 SSL,因为如果你注释掉

 //smtp.Port = 465; 
 //smtp.EnableSsl = true; 

有效。