I coded a website contact form with mail send and after dozens of research cannot find an answer hoping stackoverflow users can help.
The aspx.cs file signs into the specified gmail configuration to send the email HOWEVER is there a way to set the SENDER as what the user inputs in the email textbox, so instead of recieving the email from myself so when clicking "Reply" on the mailbox its not replying to myself? If that makes sense?
So the sender is not me but the sender is what the user inputs in the mail box and I receive the email FROM the input value rather than myself
This is the solution:
- set mail.From = new MailAddress(address, display name)
- in Gmail, go to Mail Settings >> Accounts and Import.
- Add the email account you will use as sender in "Send Mail As". (tick as Alias)
This is the only way gmail will let you specify the from address.
Setting the From Address requires special configuration/confirmation in Gmail for each From Address (see here), or is otherwise prohibited.
You could create a generic gmail address such as
[email protected]. Then use the ReplyToList property to set the default Reply To email address that the user will use for their reply, to the user input email address, as well as an appropriate Display Name for the sender.
So in theory, for flexibilty use different mail service such as web host provided or outlook etc and set the mail.FROM to the value from the textbox and it will be sent from the address the user has typed? Gmail being extra secure causes confusion. Got it. Thanks guys