Sending email in ASP.NET webform on behalf of user completing form
Posted on 2011-10-08
I am trying to figure out the best way to do something that I believe should be simple and is a really common item on websites, but I am failing miserable to impliement the way I think it should work. On most websites that have a question or message form to fill in, you have a minimum of 3 standard textboxes to fill in: Your Name, Your email Address, Your message. Now I am making an assumption here that these web forms send an email to the website provider email server in question with the Name & email address in the email from field, the message in the body of the email and the rest is configured by the website form by some preset settings.
I've written this exact procedure in vb asp.net and had it working sending emails to my exchange 2007 server at my office. Then all I have to do is hit the reply button when I get the email and answer the question.
Now for the problem: I am trying to remove my exchange 2007 server because I don't have the time to maintain the server myself anymore and want to outsource my email service. I have a google apps for domain account and an office 365 account setup that I am currently experimenting with. I have modified the code to send to both of these accounts and got them both to receive a test email. Here's the catch: The only way it works, is if the from email address is the same as the account I am sending it too, which is basically me. So I can receive an email from the website, but the from address is always the same (me) and I can never reply to anyones email, because the reply comes back to me since I am now the sender. If I try to send as the user from the input box on the form the email gets rejected from Gmail & Office 365 as a permissions problem (don't have rights to send email on behalf of that email address/user). Talking with Office 365 tech support this is probably for spam reasons. Frustrating. Now I have a wordpress website using cform and it will send an email to the gmail account without a problem (haven't tried office 365 yet) showing the email coming from the user input box, exactly the way I am trying to do in asp.net. Now I don't want to use wordpress for this function, I need an asp.net website so I can take advantage of some vb code I want to use on the form. The wordpress cform has obviously found a way around this problem, but I cannot find similar solution in asp.net, remembering that I am trying to down the number of computers/servers that I am maintaining.
I have to believe that someone has run into this same problem out there and that there are lots of asp.net websites doing what I am trying to accomplish. I really don't want to keep runing this exchange server, but will if I have too. I believe the key is in the asp.net code I am using, because I didn't do anything special with the wordpress site to make it work with gmail. Any suggestions/solutions on how to solve my problem?