简体   繁体   中英

Sending mail from website in ASP.NET

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

From comments:

This is the solution:

  1. set mail.From = new MailAddress(address, display name)
  2. in Gmail, go to Mail Settings >> Accounts and Import.
  3. 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 no-reply-yourapp@gmail.com . 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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM