When I use outlook, I am able to send test email to my gmail address, however, when I do it from a console application it triggers : "The server response was: 5.7.1 Unable to relay"
using System.Net.Mail;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
MailMessage mail = new MailMessage("xxx@myCompany.com", "xxx@gmail.com");
SmtpClient client = new SmtpClient();
client.Port = 25;
client.DeliveryMethod = SmtpDeliveryMethod.Network;
client.UseDefaultCredentials = false;
client.Host = "xxx.xxx.com";
mail.Subject = "this is a test email.";
mail.Body = "this is my test email body";
client.Send(mail);
}
}
}
I verified that i have the correct client host through outlook. I also sent a test email to myself (from xx@mycompany to xx@mycompany) and that worked (although it sent it to the junk box). Why will it not let me send outgoing emails through this console app, but I can through the same address in outlook.