Send Email functionality is not working at the server machineHello Guys,
I have created a Windows Application using C# and implemented the Send email code for sending emails. The code for sending email is working fine in the local but not sending email to a machine which is located in other country. Is the send email functionality dependent on the Country? I am using gmail as the intermediate server for sending email.
Below is the code which I am using for sending email:
private bool MailSend(string fromEmail, string toEmail, string subj, string content, string userName, string password, string smtpServer, int portNumber)
bool isSent = false;
var msg = new MailMessage(fromEmail, toEmail, subj, content);
var smtp = new SmtpClient(smtpServer)
Port = portNumber,
EnableSsl = true,
Credentials = new NetworkCredential(userName, password)
isSent = true;
catch (Exception ex)
MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
And then I am calling like this:
bool bSent = MailSend("firstname.lastname@example.org", txtToEmail.Text.Trim(), txtSubject.Text.Trim(), txtMessage.Text.Trim(), "email@example.com", "xxxxxxxxxx", "smtp.gmail.com",587));
MessageBox.Show("mail sent successfully", "send email");
lblSendingEmail.Visible = false;
MessageBox.Show("there might be some issue in sending email.", "send email");
The server machine is using Windows 7 as the Operating system. Do we need to do any settings in the Windows 7 machine. I tried by disabling all the antivirus and Windows Firewalls but still the same problem.
Do we need to enable the SMTP in the Windows machine for sending email? If anyone has any idea, please share it.
Thanks in advance.