locked
Issue in sending Email to some specific set of Mail address: c# .Net RRS feed

  • Question

    1. In our requirement, we are working on an issue

         Issue : The e-mail is not getting delivered to some specific Email Id.
    2. In C# we are having a method to send E-mail. It's working fine, but for some clients the email is not getting delivered e.g.client@abc.com.

      c# code (Modified):

      smtpClient = new SmtpClient();
      mailMessage = new MailMessage();
      mailMessage.Subject = subject;
      mailMessage.IsBodyHtml = true;
      mailMessage.From = new MailAddress(from);
      mailMessage.To.Add(new MailAddress(to));
      mailMessage.CC.Add(new MailAddress(cc));
      mailMessage.Body = string.Format("{0}", body);
      smtpClient.Host = host;
      smtpClient.Port = port;
      smtpClient.Send(mailMessage);
    3. we tried sending the Email to the same client through JAVA code, the email got delivered with out any issue.

      Java Code(modified):

      Session session;
      Properties props = System.getProperties();
      props.put( "mail.smtp.host", smtpHost);
      props.put("mail.smtp.from",smtpHeader); 
      session = Session.getDefaultInstance( props, null);
      Message message = new MimeMessage(session);
      message.setFrom(new InternetAddress(from));
      message.setRecipients(Message.RecipientType.TO,InternetAddress.parse(to));
      message.setSubject("Testing Subject");
      message.setText("Test Email");
      Transport.send(message);
    4. we are searching for the solution to send the Email through C#.Net code.

    Any good solutions are appreciated.

    Note: 

    1. we are not having access for the destination server log, if it is caught in a spam filter then i don't know how come the same is possible in java code?

    2. The host and port are same as the java code.

    3. The host and port are configured properly, actually the method is working properly for other Email id

    Thanks in advance.


    • Edited by Selva.123 Monday, December 10, 2012 12:00 PM Formatting
    • Moved by Bob Shen Tuesday, December 11, 2012 5:15 AM (From:Visual C# General)
    Monday, December 10, 2012 11:50 AM

All replies

  • Hi Selva.123,

    According to your description, I'd like to move this thread to Network Class Library (System.Net)Forum for better support, where more experts live.
     
    Thanks for your understanding.


    Bob Shen
    MSDN Community Support | Feedback to us
    Develop and promote your apps in Windows Store
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Tuesday, December 11, 2012 5:14 AM
  • You didn't post all the paramters to tell me what type of connection you are using.  SMTP supports a number of different connection methods.

    1) Use  local SMTP server

    2) Use a remote Outlook server

    3) Use a remote SMTP server like gmail

    You also have two methods of setting up credentials

    1) Specify the credentials in the C# code

    2) Use the users email credentials that are configured on the PC in the control Panel - email settings.  This could either be an Outlook Email Account or a POP account.

    You also have the options with SMTP to use your IE Browser certificate and cookies.  SMTP also has options to use SSL or TTL encryption and to use remote proxy servers.  In some cases you need to use Port forwarding to get through a firewall or virus protection software.

    You provided a limited amount of code to help me determine where the exact cause of the problem lies.  The differences between using Java and Net Library functions is the Java will default to using IE settings while Net Library SMTP will not default to the IE settings.

    I often use wireshark in cases like this to compare the network messages between an application that works and an application that doesn't work to get my software working.


    jdweng

    Tuesday, December 11, 2012 5:22 PM
  • Actually if you can get the log from relaying SMTP server, you should be able to identify the issue.

    The fact that you can send the mail to "some" mailbox indicates the code and mail setting is correct. (Note that mailbox in your company shouldn't be counted in the "some mailboxes" in this line.) Maybe it's indeed some content in the mail triggered blocking rules in spam filters.

    You may also check whether your relaying SMTP server got enlisted in various spam blocking lists. If your SMTP server is there, it doesn't help to take any other action before you got it removed. Note that some blocking list make need 6-12 hours for the status update to pass to the destination mail server.


    • Edited by cheong00 Saturday, December 15, 2012 2:55 AM
    Saturday, December 15, 2012 2:54 AM
  • telnet smtpserver ip(example 127.0.0.1)   port(25)
    helo Name
    mailfrom: abcdef@abc.com
    rcptto: 12345@example.com
    data
    fasdasdasdasdasd 
    .

    Hi,

    Please test using the above.

    Also verify the MX record for the domain. 

    Regards


    Please remember to mark the replies as answers if they help and unmark them if they provide no help , or you may vote-up a helpful post


    Monday, December 17, 2012 6:36 AM