I couldn't send mail using smtp ASPMX.L.GOOGLE.COM. I have domain domain.co.in and email address test@domain.co.in which is accessible in gmail. i Could send mail manually but not programmatically. throws below error. Service not available, closing transmission channel. The server response was: 4.7.0 [61.16.142.134 15] Our system has detected that this message is
MailAddress ma_from = new MailAddress("test@domain.co.in", "fromName");
MailAddress ma_to = new MailAddress("jrao.XXXX@gmail.com", "fromName");
string s_password = "TestPwd";
string s_subject = "Test";
string s_body = "This is a Test";
SmtpClient smtp = new SmtpClient
{
Host = "ASPMX.L.GOOGLE.COM",
Port = 25,
EnableSsl = true,
DeliveryMethod = SmtpDeliveryMethod.Network,
UseDefaultCredentials = false,
Credentials = new NetworkCredential(ma_from.Address, s_password)
};
using (MailMessage mail = new MailMessage(ma_from, ma_to)
{
Subject = s_subject,
Body = s_body
})
smtp.Send(mail);