Runtime smtp settings

Hi,
How can i have runtime smtp settings. I need to change the settings
depending on from which email address(smetimes Yahoo, sometimes gmail)
i need to send the mail
Thank you.