Skip to main content
Help Center
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

SMTP mail is not sending using godadddy configuration

0 I am not able to send mail using Below code after hosting it in Godaddy space. I tried "relay-hosting.secureserver.net" with port 25 without specifying the credentials. But the result was same. public async Task Post([FromBody] EmailModel value) { try { string message = BuildMessageBody(value.toname, value.toemail, value.contact); using (var client = new SmtpClient()) { var networkCredential = new NetworkCredential { UserName = _configuration["Email:Email"], Password = _configuration["Email:Password"] }; client.Credentials = networkCredential; client.Host = "smtpout.secureserver.net"; client.Port = 465; client.EnableSsl = true; using (var emailMessage = new MailMessage()) { emailMessage.To.Add(new MailAddress(value.toemail)); emailMessage.From = new MailAddress(_configuration["Email:Email"]); emailMessage.Subject = value.subject; emailMessage.Body = message; emailMessage.IsBodyHtml = true; emailMessage.BodyEncoding = System.Text.Encoding.UTF8; emailMessage.SubjectEncoding = System.Text.Encoding.Default; emailMessage.ReplyToList.Add(new MailAddress(_configuration["Email:Email"])); client.SendCompleted += (s, e) => { client.Dispose(); emailMessage.Dispose(); }; await client.SendMailAsync(emailMessage); await Task.FromResult(0); _appLogger.CreateLog("Passed Step 1 "); } } return StatusCode(StatusCodes.Status200OK); } catch (Exception ex) { _appLogger.CreateLog("SendEmail - " + ex.Message); return StatusCode(StatusCodes.Status500InternalServerError); } }
0 REPLIES 0