Hi I want to send password validation to my users using c#, and I wish to protect my mail box getting spammed. How do I do that?
Been trying to this and it's not working:
SmtpClient smtpClient = new SmtpClient("smtp.gmail.com", 587);
smtpClient.EnableSsl = true;
smtpClient.Timeout = 10000;
smtpClient.DeliveryMethod = SmtpDeliveryMethod.Network;
smtpClient.UseDefaultCredentials = false;
smtpClient.Credentials = new NetworkCredential("login", "password");
MailMessage mailMsg = new MailMessage();
mailMsg.From = new MailAddress("[email protected]");
mailMsg.To.Add("user");
mailMsg.CC.Add("[email protected]");
mailMsg.Bcc.Add("[email protected]");
mailMsg.Subject = "Subject";
mailMsg.Body = "BodyOfTheMailString";
smtpClient.Send(mailMsg);
Console.WriteLine("Mail sent");
The user i am sending this email to, getting my gmail account as the sender
This is not C#'s task, neither the body of your message: its your mailbox configuration.
If this is just for email validation, you can always create a new email like "[email protected]" or "[email protected]" for sending these verifications messages and then set this mailbox to ignore incoming messages.
Also if you try to send messages using emails that are not registered into your server, the server can deny your request.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With