It's pretty much the same as setting up your mail program on your PC: you need to specify the outgoing mail server, the user name, and the password (and possibly the port number if not the usual "25"). For instance, if using PHPMailer, you would set up the connection something like:
require_once "class.phpmailer.php";
$mail = new phpmailer();
$mail->Mailer = 'smtp';
$mail->Host = 'mail.example.com';
$mail->From = 'foobar@example.com';
$mail->UserName = 'foobar';
$mail->Password = 'abc123';
$mail->FromName = 'John Doe';