Override Sender / Return-Path not working

Hi,

i am bumping this old thread because it seems that this feature was never implemented and i am urgently in need of this functionality.

To recap: Even if i set the “Return-Path” header to some email address as suggested in this thread, this header is ignored by the SmtpClient class, instead when sending the envelope information to the SMTP server, the SmtpClient uses either Sender or From properties of the MailMessage class to get the value for the “MAIL FROM” envelope attribute.

I am not quite sure that using the “Return-Path” header is the best way to provide this information for the SmtpClient. Maybe you could provide a new property in the MailMessage class (name for example EnvelopeSender) or a property and/or method parameter in the SmtpClient class…

Please let me know what you thing and possibly an ETA for this feature.
Thank you
Regards
Robert

Hi Robert,


Thank you for considering Aspose.

Just to let you know that I have split the existing thread into a new post to investigate this issue in a different perspective. Moreover, the ticket (NETWORKNET-15562) attached to the old thread was closed by the development with the status “Not a Bug”. The reason being, while transporting a message, it can go through a chain of servers. Each server adds a header with Return-Path field to the message. If we assign Return-Path field different from sender’s address before sending the message, the following servers will overwrite the Return-Path on the sender’s address. Therefore, I believe adding Return-Path to the message is not a suitable solution for your situation.

To better understand your request, could you please elaborate your scenario in more detail with the help of code snippets? Are your using the TemplateEngine class? Have you tried the latest of Aspose.Email for .NET v1.6.0?

Looking forward to your kind response.
Regards,

Hello Babar,

thank you for your reply, i will try to explain our situation and what we want to achieve.

We are using Aspose components to create and send emails from support agents to customers.
We want the the mails to go out with the agent’s email address as the sender (“From” header in the mail message).
In case these mails bounce we want those bounces go to the a predetermined bounce mailbox and not to the agent’s mailbox.

We are using the “Errors-To” mail header to try to steer the bounces to the bounce mailbox but the Errors-To is Non-Standard so this works only rarely.
After researching the possible solutions i concluded that the only way to control where the bounces would be sent is to control the envelope information that the SmtpClient class sends to the SMTP Server as the value in the “MAIL FROM” command.
Please be aware that this is not the same as the From header - the from header is part of the message itself, on the other hand the MAIL FROM envelope information is part of the SMTP protocol communication and is send at the beginning of the session before the actual email data is transmitted.
Please see also this article: Bounce address - Wikipedia

The problem is that in the current implementation of the SmtpClient class, the client uses the value from the Sender or the From property of the MailMessage class in the MAIL FROM command .
What i need is a way to supply a different email address for the MAIL FROM command.
Now that could be done in several ways… preferably a new dedicated property of the MailMessage class (named for example EnvelopeFrom) or alternatively a property on the SmtpClient class and/or a method parameter in the Send method.

I mentioned the Return-Path header only because it was part of the discussion in the previous thread and could be an alternative way of providing the information to the SmtpClient.
As you can see, in my previous message i wrote that i am not sure that that would be the best way to do it anyway.
I would actually prefer the dedicated property of the MailMessage class.

I did not provided any code example because there is nothing to show in code.
We also do not use the TemplateEngine but i can imagine that templating could be also useful for this new property.
I also confirmed that the behavior of the SmtpClient class in the latest Aspose.Email version is as described.

I hope my explanation helped to understand my feature request and i am looking forward to your response.
With regards
Robert

Hi Robert,


Thank you for the explanation.

I have requested the development team to analyse your requirement and provide their feedback with appropriate solution for your need. The request has been logged under ticket Id NETWORKNET-33228 and same has been attached to this thread for tracking purposes.

We will keep you informed of any developments regarding the support of this feature via this forum thread.

Hello,

any news regarding our request? We need this feature quite badly.
Thank you
With regards
Robert

Hi Robert,


Thank you for writing back.

I am afraid, your requested feature is currently pending for analysis, and is in the queue. Therefore at the moment we can’t provide an estimate for it’s implementation. As soon as we have made some significant progress, we would be more than happy to update you with the status. Please be patient and spare us little time.

Thank you again for your cooperation and understanding.
Regards,

Hello,

do you have any updates on the progress?
Thanks.
Robert

Hi Robert


My sincere apologies for any inconvenience caused to you.

I have checked the ticket status and found that its planned in Aspose.Email for .NET 1.9.0. As soon as I get some more feedback from my developer, it will be notified to you.

Best Regards

Hi Robert,


I am writing in reference to the ticket logged earlier as NETWORKNET-33228.

We have analyzed your scenario and we have found that the required functionality is already present is Aspose.Email for .NET component. Important point to note is that you may use this feature only in case if your SMTP server supports this functionality. If you are using public SMTP servers like GMail, Yahoo and so on, you can’t use this feature because these servers simply don’t support it. Most of the ISPs which provide internet access to private end-users (Not business customers) support this option, so you may check it at home if your office SMTP server don’t allow you to do it.

Thank you for your understanding.

Hi Babar,

could you please provide details about this feature? How was the functionality implemented? Can you please provide a source code example?
We want to use this functionality with our internal SMTP server.

Thank you.
Robert

Hi Robert,


Please find below the source code for your reference. Please note we have tested the sample with a private mail account provided by the ISP.

C#

MailMessage mailMessage = new MailMessage("from@domain.com", "to@domain.com");
mailMessage.Subject = “test”;
mailMessage.Body = “test”;
mailMessage.BodyEncoding = Encoding.UTF8;
mailMessage.Priority = MailPriority.High;
using (SmtpClient client = new SmtpClient(“host address”, 25, “username”, “password”))
{
client.SecurityMode = SmtpSslSecurityMode.Implicit;
client.EnableSsl = true;
client.Send(mailMessage);
}

As you may notice we are simply creating a new MailMessage instance by specifying the Sender and Recipient email addresses and sending it through the SmtpClient. SmtpClient ctor uses login (not email address) and password to authenticate you on the server. Usually login has the same value as of email address therefore SmtpClient always transmit ‘From’ field (in MailMessage class) to the Smtp server.

Server decides which FROM-field is used.
  1. Server may be configured to use FROM-field which is transmitted from client to server.
  2. Server may be configured to use data from the user account which is used to login to Smtp server.

Usually public and corporate servers do not allow 1) because public servers in such way prevents spam. Where as the corporate server have all required information in users profiles but the corporate server may be configured to allow this.

Regards,

Hello Babar,

i am afraid what you described is not the functionality that we requested. Please look at my explanation in the third post of this thread.
We need to define the value that the SmtpClient sends as part of the MAIL command, this is not the same as the From-Header of the mail message nor is it the same as the user name or email address associated with the user account that was used to authenticate the SMTP connection (it is also possible that the connection is made without authentication).

Please see [RFC 5321 Section 3.3](http://tools.ietf.org/html/rfc5321#section-3.3) for the detail about the MAIL command. Here is a citation from :

The first step in the procedure is the MAIL command.

  MAIL FROM:<reverse-path> [SP <mail-parameters> ] <CRLF>

This command tells the SMTP-receiver that a new mail transaction is
starting and to reset all its state tables and buffers, including any
recipients or mail data. The portion of the first or
only argument contains the source mailbox (between “<” and “>”
brackets), which can be used to report errors (see [Section 4.2](http://tools.ietf.org/html/rfc5321#section-4.2) for a
discussion of error reporting).

With regards
Robert

Hi Robert,


I am so sorry for the inconvenience caused to you.

You are right that we have misunderstood your requirement. On further analysis, we have found that the required functionality (bounce the message to another email address than the Sender) is yet not supported by Aspose.Email for .NET component. We are currently working hard to provide this feature in our upcoming release under the same ticket already attached to this thread.

Thank you for share more information and for your patience.

Hi Again,


With upcoming release of Aspose.Email for .NET v2.0.0, we have added a new property by name of ReversePath to the Aspose.Email.Mail.MailMessage class. Below are some details,

public virtual MailAddress ReversePath

When you want to override the email address for non-delivery notification messages, please fill this property with email address where you want to receive the bounced emails.

Please note, SMTP server may have to be configured in order to override the ReversePath value.

Regards,

The issues you have found earlier (filed as NETWORKNET-33228) have been fixed in this update.


This message was posted using Notification2Forum from Downloads module by aspose.notifier.