This is a rudimentary example, ofcourse there are better examples out there but this will hopefully give you an idea on how it's done.
Hope it helps!
<?php
$smtp = @fsockopen("IP_Address",25,$errno,$errdesc,30);
if(!$smtp)
{
print "Could not connect to SMTP server";
}
else {
print "Connect to SMTP server\n";
print fgets($smtp,256);
$helo = fputs($smtp, "helo server\n");
print fgets($smtp,256);
$send = fputs($smtp, "MAIL FROM: <Email address>\n");
print fgets($smtp,256);
$send2 = fputs($smtp, "RCPT TO: <Email address>\n");
print fgets($smtp,256);
$send3 = fputs($smtp, "DATA\n");
print fgets($smtp,256);
$send4 = fputs($smtp, "HELLO HELLO JUST TESTING\n.\n");
print fgets($smtp,256);
fputs($smtp,"QUIT\n");
print fgets($smtp,256);
fclose($smtp);
}
?>