c# - How Can i send the email from the MVC4 to my gmail without using my password? -
this methode in contactus controller.
[httppost] public string sendemail(string username, string useremail, string usermobile) { var success = "success"; var fromemail = useremail; var toemail = webconfigurationmanager.appsettings["email"]; var password = webconfigurationmanager.appsettings["password"]; var body = userdescription; var mobile = usermobile; var smtp = new smtpclient { host = "smtp.gmail.com", port = 587, enablessl = true, deliverymethod = smtpdeliverymethod.network, credentials = new networkcredential(toemail, password)//here dont want speciefie pasword // credentials=new networkcredential() }; using (var message = new mailmessage(fromemail, toemail) { body = body }) { smtp.send(message); } return success.tostring(); }
in webconfig file have specified username , password , if try send mail working fine not supposee speciefie password in we.config file need speciefie email not password...
here webconfig code...
<appsettings> <add key="email" value="chandru@yadnom.com"/> <add key="password" value="xxxxxxxxx"/> </appsettings>
if means workingbut dont want specifie password in web.config want speciefie email address..
so me how can this..
thanks in advance...
you can not use smtp.gmail.com
without authentication, google policy.
to around issue could:
- encrypt password in configuration file (as suggested bendataclear)
- use smtp server not require authentication
Comments
Post a Comment