一个开发人员被传递了值,这个方法曾经工作过,但突然停止了。我不记得更改过任何会对Gmail API产生直接影响的内容。请帮忙,我明天需要把这个给雇主看。
public void SendEmail(Developer developer)
{
var userId = this.User.FindFirstValue(ClaimTypes.NameIdentifier);
var loggedInEmployer = _context.Employers.Where(e => e.IdentityUserId ==
userId).SingleOrDefault();
var fromEmail = loggedInEmployer.Email;
var toEmail = developer.Email;
var fromAddress = new MailAddress(fromEmail, loggedInEmployer.UserName);
var toAddress = new MailAddress(toEmail, developer.UserName);
string fromPassword = MyKeys.passcode;
const string subject = "Hired On DevWorks";
string body = "Congratulations " + loggedInEmployer.UserName + " Has Hired you for contract at " + loggedInEmployer.CompanyName + "!";
SmtpClient smtp = new SmtpClient
{
Host = "smtp.gmail.com",
Port = 587,
EnableSsl = true,
DeliveryMethod = SmtpDeliveryMethod.Network,
Credentials = new NetworkCredential(fromAddress.Address, fromPassword),
Timeout = 20000
};
using (var message2 = new MailMessage(fromAddress, toAddress)
{
Subject = subject,
Body = body
})
{
smtp.Send(message2);
}
}
我最近更改了Gmail密码。一个简单但常见的错误。