You need understand how smtp server works first.
You can get mx hosts for recipient email-domain from dns and then send email to this host on port 25 (always) without own smtp server (open port 25 on firewall on local firewall): How to, using PHP, ping an SMTP server and check MX records? or with phpMailer.
Get domain dns mx records/hostnames (PHP)
function getMX($hostname = "boo.xx", $show = 0){
if(dns_get_mx($hostname, $mxhosts, $weights)) {
$i = 0;
$mxList = NULL;
foreach($mxhosts as $key => $host) {
if($show == 1) echo "Hostname: $host (Weight: {$weights[$key]}) <br>";
$ip = gethostbyname($host);
if($show == 1) echo "IP " . $ip . "\n<br>";
if($show == 1) echo "IP " . gethostbyaddr($ip) . "\n<br>";
$mxList[$i]['host'] = $host;
$mxList[$i]['ip'] = $ip;
$mxList[$i]['weight'] = $weights[$key];
$i++;
}
return $mxList;
} else {
echo "Could not find any MX records for $hostname\n";
}
}