I am trying to send mail from gmail and it's sent successfully in localhost but when publish website on server didn't send

JAY SINGH YADAV 1 Reputation point
2022-06-18T07:09:33.607+00:00

My Code Running fine on Local Host.

mail.From = new MailAddress("xyz@Stuff .com");
mail.To.Add(ObjBE.Email1);
mail.Subject = Subject;
//mail.Priority = MailPriority.High;
mail.Body = body;
mail.IsBodyHtml = true;

                        using (SmtpClient smtp = new SmtpClient("smtp.gmail.com", 25))//For Local use 587 Port  
                        {  
                            smtp.UseDefaultCredentials = false;  
                            smtp.Credentials = new NetworkCredential("xyz@gmail.com", "*********");  // **** is gmail Secure Password.                                
                            smtp.EnableSsl = true;  
                            smtp.Send(mail);  
                             

                        } 
Internet Information Services
.NET
.NET
Microsoft Technologies based on the .NET software framework.
3,342 questions
ASP.NET
ASP.NET
A set of technologies in the .NET Framework for building web applications and XML web services.
3,243 questions
{count} votes