I am writing a script to send email using Mailx. I am assuming that sSMTP would be a better solution to send mail via a remote SMTP server at the mail account hosting provider.

How can I set the remote SMTP, User/Passwd etc. settings, I guess in sSMTP, only for the duration of the script and reset when the shell exits?

Alternative suggestions on how to achieve this in a simpler way, perhaps without sSMTP, are also welcome. I cannot send these messages as root. I wish to use one of the few accounts that I have setup at my hosting service. So sender name, login, password, etc. have all to be handled.