-1
I’m having a boring mistake, I can’t fix it a few days ago.
I searched, but I couldn’t find anything on how to remove it.
Error:
The SMTP server requires a secure connection or the client was not authenticated. Server response was: 5.5.1 Authentication Required. Learn more at
Code:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.IO;
using System.Diagnostics;
using System.Net;
using System.Net.Mail;
namespace email
{
public partial class Form1 : Form
{
private MailMessage email;
Stopwatch stop = new Stopwatch();
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
email = new MailMessage();
email.To.Add(new MailAddress(textBox1.Text));
email.From = new MailAddress(textBox3.Text);
email.Subject = textBox2.Text;
email.IsBodyHtml = true;
email.Body = textBox5.Text;
SmtpClient cliente = new SmtpClient();
cliente.Host = "smtp.gmail.com";
cliente.Port = 587;
using (cliente)
{
cliente.Credentials = new System.Net.NetworkCredential(textBox3.Text, textBox4.Text); //credenciais, senha e email
cliente.EnableSsl = true;
cliente.Send(email);
}
MessageBox.Show("email enviado");
}
}
}
It didn’t work either, man. I tried switching to the console and even made another form, even putting the right credentials, this error happens.
– João silva
What version of . NET are you using? And what is the operating system of the machine you are running the application on? Maybe it’s a matter of TLS version...
– Jônatas Hudler