How can I replace the smtp server configured in discourse?

If what you want to do is change the SMTP settings you can

cd /var/discourse
./discourse-setup

and it’ll let you change the settings and rebuild when you’re done