I have an .ASPX
webform that collects information from a user and is supposed to email that information to one of our email addresses, similar to a "contact us" style form.
I would like for the email to appear to be sent from the email address that the user provides when completing the form, that way whoever receives the email can simply click "reply" to reply to the user who completed the form.
The problem I am running into is that our Office 365 Exchange account isn’t allowing the emails to be sent. If we use our own email address on the form, the emails will send, but if I put in my gmail email address, for example, the server refuses to send the email and says that the user has no permission to send on behalf of that email address.
I have tried setting the sender and the from properties to different values, and it still refuses to send. Our old mail server did allow this to work, but the Office 365 mail server wont.
I’m not worried about spam, considering that we are still authenticating with the Office 365 Exchange server, and the recipient of all the messages is the same and is an email that is a registered user on our Office 365 Exchange service. If anything, we would be the one getting spammed by robots completing the form.
I understand that Office 365 Exchange probably doesn’t allow relaying like this for spam and security reasons, but is there a way to allow relaying if it’s always from the same IP address, or always to the same Exchange email account?
I can’t imagine that we would have to have our web form submissions always be sent by our own email addresses, that just seems odd to me.
Any ideas or just a "Yeah, you can’t do that" would be really helpful.
Thanks!
2
Answers
This so called email "relay" is not allowed unless you change some security, and in most cases, you can’t.
However, a simple solution is to set the "reply to" setting when sending the email using the .net smtp client.
So, when users hit reply, you can have any email you want. The sender can’t easily be changed, and that’s due to emails being hijacked.
Stealing of emails? Well, you don’t want someone stealing that email, and sending out 1 or 2 million emails based on that account. In fact, this is why most email senders and server’s now don’t allow such "relay" sending. It is just too dangerous and opens up too many doors for abusing and allowing anyone to send a email on behalf of someone else.
Just use the Reply to setting in the email object, that solves what happens when users hit reply.
So, you can certainly setup a email account to be used for all web sending of emails from the site (permission for such a relay can be setup).
However, having a the sender as someone’s else’s actual email account? Nope, it just not really allowed anymore.
Thankfully, the "reply to" option was introduced to near all email objects.
You need to use the mailto: protocol if you want users to send emails from their email accounts.
Otherwise, when the user submits a form from the web site you can send an email from your Office365 account with a
ReplyTo
property set to the user email address.