i'm try to send some simple email to for example test@blabla.com
First of all, I've already tried it in my Localhost, and it worked, the problem was when i uploaded it to my Server
the Server i'm using is windows server 2012 R2, with IIS 7 (not really sure with the version but i believe it's 7 and above) hosted successfully with no problem, just the send email method don't work...
I've already add SMTP feature, set the SMTP E-MAIL(Yes, there are no SMTP Virtual server in IIS 7 and above)
here's my controller
public ActionResult SendTestEmail()
{
var test_address = "test@blabla.com";
try
{
// Initialize WebMail helper
WebMail.SmtpServer = "localhost";
WebMail.SmtpPort = 25; // Or the port you've been told to use
WebMail.EnableSsl = false;
WebMail.UserName = "";
WebMail.Password = "";
WebMail.From = "admin@testserver.com"; // random email
WebMail.Send(to: test_address,
subject: "Test email message",
body: "This is a debug email message"
);
}
catch (Exception ex)
{
ViewBag.errorMessage = ex.Message; // catch error
}
return View();
}
here is my SMTP E-mail settings:
the error message are: Mailbox unavailable. The server response was: 5.7.1 Unable to relay for test@blabla.com (this happens when i leave the E-mail address textbox empty, this also happens when i've entering any email format such as sample@email.com / my primary e-mail)