smtp_send()


通过SMTP向邮件传送

Description

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

Parameters

Return Value

成功时服务器应答信息,失败时空字符串("")或是没有接到应答时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