.Net smtp does not send emails, no errors

I am trying to send email through a web application using my organization client email server. Below is the code I'm using.

MailMessage MyMailMessage = new MailMessage();
MyMailMessage.Subject = "Email testing";
MyMailMessage.From = new MailAddress("name@mydomain.com", "My name");
MyMailMessage.To.Add(new MailAddress(strEmail, "Applicant"));

SmtpClient mySmtpClient = new SmtpClient();
mySmtpClient.EnableSsl = true;
mySmtpClient.Send(Accepted);

Web.config file:

<mailSettings>
  <smtp deliveryMethod="Network" from=" name@mydomain.com">
    <network host="smtps.mydomain.com" port="465" enableSsl="true" defaultCredentials="true"
    userName="myName" password="myPassword" />
  </smtp>
</mailSettings>

It works fine when I use the gmail smtp details or the smtp details of my local organization. For some reason, it does not work, and does not cause any errors.

I tried debugging and checking for an exception that says "timeout".

I'm not sure what else to check. Maybe someone can suggest a solution.

Note. I also checked that the firewall is not blocking port: 465.

Thanks.

Yours faithfully,

Sud

+4
source share
5

:

var sysLogin="yourlogin@gmail.com";
var sysPass="y0urP@ss";
var sysAddress = new MailAddress(sysLogin, "Message from me!");

var receiverAddress = new MailAddress("mike@hotmail.com");

var smtp = new SmtpClient
        {
            Host = "smtp.gmail.com",   //gmail example
            Port = 587,
            EnableSsl = false,
            DeliveryMethod = SmtpDeliveryMethod.Network,
            UseDefaultCredentials = false,
            Credentials = new NetworkCredential(sysLogin, sysPass)
        };

        using (var message = new MailMessage(sysAddress, receiverAddress) { Subject = "Some subject", Body = "Some text" })
        {
            smtp.Send(message);
        }
+1

, SMTP- SSL 465?

, , WireShark, .

SysIntenerals TcpView - , .

+1
<system.net>
    <mailSettings>
      <smtp from="emialid.com">
        <network host="domain.com" port="25" userName="emialid.com" password="******" defaultCredentials="false"/>
      </smtp>
    </mailSettings>
    </system.net>



public string SendEmailTest(String EmailMessage, String FromMail, String MailPassword, String MailServer, String To, String CC, String BCC, String DisplayName, String Subject, String Attachment)

    {
        try
        {
            SmtpClient smtpClient = new SmtpClient();

            MailMessage message = new MailMessage();

            MailAddress fromAddress;

            fromAddress = new MailAddress(FromMail);

            smtpClient.Host = MailServer;
            smtpClient.Port = 25;

            System.Net.NetworkCredential SMTPUserInfo = new System.Net.NetworkCredential(FromMail, MailPassword);
            smtpClient.UseDefaultCredentials = false;
            smtpClient.Credentials = SMTPUserInfo;

            message.From = fromAddress;

            message.To.Add(new MailAddress(To, DisplayName));
            if (CC != "")
                message.CC.Add(new MailAddress(CC, DisplayName));
            if (BCC != "")
                message.Bcc.Add(new MailAddress(BCC, DisplayName));

            message.Subject = Subject;

            message.IsBodyHtml = true;
            message.Body = "Your Password is : " + EmailMessage;

            if (Attachment != "")
                message.Attachments.Add(new Attachment(Attachment));

            message.Priority = MailPriority.High;

            smtpClient.Send(message);
            return "SendEmail";
        }
        catch (Exception ex)
        {
            return "Email :" + ex;
        }

    }
}

}

+1

, "telnet smtps.mydomain.com 465" Command Promt (cmd).

+1

. , 465 25.

0

All Articles