나는 이것에 대한 많은 질문과 답변을 알고 있으며 할당량을 읽었지 만 모두 구식 인 것 같습니다.Gmail을 통해 메일 보내기
그래서 모바일 서비스를 사용하여 클라우드 서비스에 등록한 다음 사용자의 이메일 주소로 환영 이메일을 전송합니다.
static void SendMail()
{
var fromAddress = new MailAddress("gmail account", "App name");
var toAddress = new MailAddress("User email", "User account");
const string fromPassword = "gmail password";
const string subject = "test";
const string body = "Hey now!!";
var smtp = new SmtpClient
{
Host = "smtp.gmail.com",
Port = 587,
EnableSsl = true,
DeliveryMethod = SmtpDeliveryMethod.Network,
UseDefaultCredentials = false,
Credentials = new NetworkCredential(fromAddress.Address, fromPassword),
Timeout = 20000
};
using (var message = new MailMessage(fromAddress, toAddress)
{
Subject = subject,
Body = body
})
{
smtp.Send(message);
}
Console.WriteLine("Sent");
Console.ReadLine();
}
내 코드를 사용하는 다른 사람에 의해 제안 모든 것 : 서비스 부분은 C# WCF 마녀에서 이루어집니다
은 아래 메일에 대한 테스트를위한 프로토 타입 기능은 메일
에게 보냅니다. 하지만 난 여전히 오류 메시지가
An unhandled exception of type 'System.Net.Mail.SmtpException' occurred in System.dll
Additional information: The SMTP server requires a secure connection or the client was not authenticated. The server response was: 5.5.1 Authentication Required. Learn more at
시도'추가 {경우 (String.IsNullOrEmpty (센드)) 반환; }'. 당신의 함수에. 잘 모르겠지만 – BNN
변경 사항 없음 'smtp.Send (message); 줄에 오류가 나타납니다.' – Jester
무엇이 오류입니까? – BNN