Want to improve this question? Update the question so it focuses on one problem only by ed开发者_如何转开发iting this post.
Closed 2 years ago.
Improve this questioni wanna know if it is possible not to hard code my user name and password in a script that copy a file in the operation system and send it via smtp [gmail]
Thank you!
I bet that best way will be to keep password encrypted, algo is your choice. Then when user give you credentials you check if it match stored encrypted data and then send it. This will take off the step you have to keep plaintext password in any file/database. Anyway you didn't say if you realy need to keep password plain text (but it seems like a case because of remote use), if so then you should use 2-way encryption to avoid plain text passwords - it can be breaked easy but still needs one more step than just read the config file.
Store your data as environment variables or inside a configuration file...
make the script take the username as command line args.
if you import sys, then sys.argv is the list of all command line args, where the first is the name of the python script itself.
精彩评论