1

I am trying to set the 'return-path' for my emails but I'm not seeing it as an available parameter. It seems like replytolist is not the same thing. I wan't to set the location that bounced emails are delivered. Here is my code so far:

    private static void SendMail(string html,string taxId,string toEmail,string filePath,string fromEmail,string replyToEmail,string emailSubject,string emailAttachPath)
    {
        try
        {
            MailMessage mail = new MailMessage();     
            mail.From = new MailAddress(fromEmail);
            mail.To.Add(toEmail);

            mail.Subject = emailSubject;
            mail.Body = html;

            //specify the priority of the mail message
            mail.ReplyToList.Add(replyToEmail);

            SmtpClient SmtpServer = new SmtpClient("smtp.server.com");
            SmtpServer.Port = 25;
            SmtpServer.UseDefaultCredentials = true;
            SmtpServer.EnableSsl = false;
            mail.IsBodyHtml = true;

            SmtpServer.Send(mail);

        }
        catch (Exception ex)
        {
            Console.WriteLine(ex.ToString());
        }
    }
mjanach
  • 85
  • 1
  • 9
  • 3
    [This question](http://stackoverflow.com/questions/8912861/sending-email-with-return-path-not-functioning) may be helpful. – Bob Kaufman Mar 28 '16 at 16:17
  • I set the sender attribute as suggested but I still don't get bounced email messages to the sender email address. The IT team says it's because I don't have a 'return-path' set. – mjanach Mar 30 '16 at 19:51
  • [Here's another question](http://stackoverflow.com/questions/4367358/whats-the-difference-between-sender-from-and-return-path) on the subject. The answers pretty much agree with the earlier comment. What SMTP Server are you using? Is it possibly a configuration issue with the server? Can you send messages via this server with Outlook (for example)? Do bounced messages come back to you when using Outlook (or another email client)? – Bob Kaufman Mar 30 '16 at 20:55

1 Answers1

4

If you dont write return path emailaddress. Server will take from email address convert into the return path. You also can see email report in your email original source.

enter image description here

If you want to add custom reutn path you can use

 MailMessage message = new MailMessage();
 message.Headers.Add("Return-Path", "response@*****.biz");

Also if you using postfix and you want add return path Automatically You will have to make changes in two files

  1. canonical :- put your return path emailaddress here.

    //reply@domain.com

  2. main.cf :- write your code in main.cf file

canonical_classes = envelope_sender
sender_canonical_maps = regexp:/etc/postfix/canonical

Naveen
  • 1,441
  • 2
  • 16
  • 41