Resolved Sending Email from Contact Us Page of a Website

Anonymous

Well-known member
Joined
Sep 29, 2020
Messages
84
Programming Experience
Beginner
Hello, I want to learn to send emails in C#. I want to build a contact us form where the user can just simply type his email address and write his message. Upon hitting the send button the message should get delivered to my email address(gmail account).
I have searched on internet regarding this, but every where they are doing it with SMTP which requires password of the sender. But I have seen in several contact us forms of websites where we do not need to enter the password or we don't even login. We just simply go to the contact us form and fill it, and hit the send button.

Could you please guide me how can I achieve the above mentioned functionality without the need to making user login or entering his gmail's password?

Thank you in advance for you help !
 
But I have seen in several contact us forms of websites where we do not need to enter the password or we don't even login. We just simply go to the contact us form and fill it, and hit the send button.
That's because they use their own account to send mails from and have configured this in server code.
 
I followed the steps as given in Send Email with example in ASP.Net using C# and VB.Net. But I get an exception "System.Net.Mail.SmtpException: 'The SMTP server requires a secure connection or the client was not authenticated. The server response was: 5.7.0 Authentication Required. Learn more at'".
I also got an email with a heading

Critical security alert​

Someone just used your password to try to sign in to your account from a non-Google app. Google blocked them, but you should check what happened. Review your account activity to make sure no one else has access.


I created a new gmail account then enabled it get accessed from less secure apps.

It worked !

But, is there any way we send emails without compromising the security features of gmail?

Thank you for all your help and guidance!
 
Last edited:
In general, you don't want to be using your personal account for sending emails from a server. You would setup a dedicated service account that is only ever used for that single purpose. It should have a complex random pass phrase. You would also regularly update the pass phrase every 60 days or.

Are you really forced to use Gmail as your email relay? A lot of the web hosting sites also offer email only accounts. Most of these have rules about not using your email account for spamming purposes, and they also will throttle your outbound mail if looks like your account is being abused for relaying spam.
 
Back
Top Bottom