smtp_send()


Sending an email by SMTP

Description

string smtp_send(string $rcpt_email, string $rcpt_name, string $subject, string $body)

Parameters

Return Value

response message from the server on success, empty string("") or false on fail

Example

<?php
include_once "/lib/sn_dns.php";   // including DNS library
include_once "/lib/sn_smtp.php";  // including SMTP library
smtp_hostname("from_domain.com"); // sender's host name
// sender's email address and name
smtp_account("from_id@from_domain.com", "from_name");
$subject = "email test from PHPoC";
$message = "Hi PHPoC\r\nThis is PHPoC test email\r\nGood bye\r\n";
// sending an email
$msg = smtp_send("to_id@to_domain.com", "to_name", $subject, $message);
if($msg == "221")
  echo "send mail successful\r\n";
else
  echo "send mail failed\r\n";
?>

See also