Here is my problem: I wrote whe following program to test if I can send email:
class Program
{
static void Main(string[] args)
{
try {
Console.WriteLine("Mail To");
MailAddress to = new MailAddress("myemail@gmail.com");
Console.WriteLine("Mail From");
MailAddress from = new MailAddress("me@businessdomain.it");
MailMessage mail = new MailMessage(from, to);
Console.WriteLine("Subject");
mail.Subject = "test";
Console.WriteLine("Your Message");
mail.Body = "test";
SmtpClient smtp = new SmtpClient();
smtp.Host = "mail.domain.it";
smtp.Port = 25;
smtp.Credentials = new NetworkCredential(
"username", "password");
smtp.EnableSsl = false;
Console.WriteLine("Sending email...");
smtp.Send(mail);
}catch(Exception e)
{
Console.WriteLine(e.Message);
Console.WriteLine(e.StackTrace);
}
}
}
The credentials are correct (I tested them using telnet, outlook and the app k9mail in android correctly work), the program works if I put gmail smtp setting. I really cannot understand the cause of this error.
Using wireshark I have discovered what is happening:
S: 220 server1.business.it SMTP Server ready
C: EHLO pc14
S: 250 server1.stargatenet.it Hello [87.28.219.65] | 250 PIPELINING | 250 SIZE 25000000 | 250 8BITMIME | 250 BINARYMIME | 250 CHUNKING | 250 AUTH LOGIN CRAM-MD5 DIGEST-MD5 | 250 Ok
C: AUTH login User: UsernameBase64
S: 334 VXNlcm5hbWU6
C: Pass: PasswordBase64
S: 334 UGFzc3dvcmQ6
It seems like the program is not entering the credentials when asked. How is that possible?