We are developing a .Net Windows application in C# for commercial distribution.
I want to add a function to allow the user to email a file to any email recipient from within the application without needing an email client on their PC, just an internet connection. The email they send needs to appear that it has come from them (i.e. their email address is in the FROM/REPLYTO field) so that the recipient can identify where the email has come from and they can reply to it.
I was intending to use the MailMessage class in System.Net.Mail, but it requires an SMTP server to send the email. The problem with that is, i dont want the user to have to configure anything to send emails from our application - i want it set up by us. In other words, i want to define what SMTP server to send the email from and hardcode it in the application.
I have tried to use Gmail as the SMTP server, however one major drawback - Gmail automatically rewrites the "From" line of any e-mail you send via their SMTP gateway to your Gmail address, so when we tested this, even though in the MailMessage code we set the FROM property to [email protected], when the email was received, the From field displayed [email protected]
If this software application is going to be distributed to many users in different network environments, is this method the best to use? If so, is there a free/public SMTP server i can use for our application to achieve this that will allow the end-user to define the FROM and REPLYTO fields?
I have been told that not all ISPs / organisations will permit arbitrary SMTP connections and/or if the sender implements an SPF record the message may be rejected. Does that mean my intended approach may not always work?
Is there any other common or more stable method i could use to achieve my original objective?