I am no expert by any means, but if I understand correctly, then you should use authentication to your SMTP gateway and use PEAR Mail. Plenty of internet stuff on this.
// Must have PEAR Mail Installed
require_once "Mail.php";
// Set email body
$email_body = "Hello World.";
// Setup Email Parameters
$headers = array ('From' => $email_from,
'To' => $email_to,
'Subject' => $email_subject,
'Cc' => $email_cc);
$smtp = Mail::factory('smtp',
array ('host' => $email_host,
'port' => $email_port,
'auth' => true,
'username' => $email_username,
'password' => $email_password));
// Send Email
$mail = $smtp->send($email_recpt, $headers, $email_body);