本文整理汇总了PHP中smtp::ResolveMXDomain方法的典型用法代码示例。如果您正苦于以下问题:PHP smtp::ResolveMXDomain方法的具体用法?PHP smtp::ResolveMXDomain怎么用?PHP smtp::ResolveMXDomain使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类smtp
的用法示例。
在下文中一共展示了smtp::ResolveMXDomain方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: sendtestmail
function sendtestmail($from, $to)
{
$unix = new unix();
$smtp = new smtp();
$tt = explode("@", $to);
$domainname = $tt[1];
$TargetHostname = $smtp->ResolveMXDomain($tt[1]);
echo "Connect: {$TargetHostname}\n ";
$params["host"] = $TargetHostname;
$params["helo"] = $unix->hostname_g();
if (!$smtp->connect($params)) {
smtp::events("[{$domainname}] {$domainname} -> Could not connect to `{$TargetHostname}`", __FUNCTION__, __FILE__, __LINE__);
return;
}
$body[] = "Return-Path: <{$from}>";
$body[] = "X-Original-To: {$to}";
$body[] = "Date: " . date("D, d M Y H:i:s") . " +0100 (CET)";
$body[] = "From: {$from} (Test sender)";
$body[] = "Subject: Test mail " . date("D, d M Y H:i:s");
$body[] = "To: {$to}";
$body[] = "Auto-Submitted: auto-replied";
$body[] = "MIME-Version: 1.0";
$body[] = "";
$body[] = "This is a tests mail";
$MAILDATA = @implode("\r\n", $body);
if (!$smtp->send(array("from" => $from, "recipients" => $to, "body" => $MAILDATA))) {
echo "Failed\n";
return;
}
$smtp->quit();
echo "Success from=<{$from}> to=<{$to}>\n";
}
示例2: SendTest
function SendTest($Key)
{
$GLOBALS["WRITETOFILE"] = dirname(__FILE__) . "/ressources/logs/{$Key}.log";
$sock = new sockets();
$unix = new unix();
$datas = unserialize(base64_decode($sock->GET_INFO($Key)));
$listen_addr = null;
$recipient = $datas["smtp_dest"];
$sender = $datas["smtp_sender"];
smtp::events("Resolving From {$sender} to: {$recipient}", __FUNCTION__, __FILE__, __LINE__);
if (preg_match("#(.+?)@(.+)#", $recipient, $re)) {
$domainname = $re[2];
}
if (!is_numeric($datas["smtp_auth"])) {
$datas["smtp_auth"] = 0;
}
$TargetHostname = null;
$servername = $datas["servername"];
$BinDTO = "127.0.0.1";
if ($servername != "master") {
$instance = $servername;
$main = new maincf_multi($servername);
$listen_addr = $main->ip_addr;
$BinDTO = $listen_addr;
} else {
$instance = $unix->hostname_g();
}
$smtp = new smtp();
$NOresolvMX = false;
if ($datas["smtp_auth"] == 1) {
$TargetHostname = $datas["relay"];
}
if ($datas["smtp_local"] == 1) {
$TargetHostname = inet_interfaces();
if (preg_match("#all#is", $TargetHostname)) {
$TargetHostname = "127.0.0.1";
}
smtp::events("Local, instance {$servername}: Sock to `{$TargetHostname}`", __FUNCTION__, __FILE__, __LINE__);
if ($servername != "master") {
smtp::events("Local, instance {$servername}: changed to inet_interfaces()::{$TargetHostname}", __FUNCTION__, __FILE__, __LINE__);
$TargetHostname = $listen_addr;
}
}
if ($TargetHostname == null) {
$TargetHostname = $smtp->ResolveMXDomain($domainname);
smtp::events("Resolving {$domainname} = `{$TargetHostname}` bind address: {$BinDTO}", __FUNCTION__, __FILE__, __LINE__);
}
$params["helo"] = $instance;
$params["bindto"] = $BinDTO;
$params["debug"] = true;
smtp::events("smtp_auth: {$datas["smtp_auth"]}, user:{$params["user"]},relay:{$datas["relay"]} ", __FUNCTION__, __FILE__, __LINE__);
smtp::events("Me: HELO: {$instance}", __FUNCTION__, __FILE__, __LINE__);
if ($datas["smtp_auth"] == 1) {
$params["auth"] = true;
$params["user"] = $datas["smtp_auth_user"];
$params["pass"] = $datas["smtp_auth_passwd"];
if (trim($datas["relay"]) == null) {
if ($TargetHostname != null) {
$datas["relay"] = $TargetHostname;
}
}
$TargetHostname = $datas["relay"];
}
$params["host"] = $TargetHostname;
if (!$smtp->connect($params)) {
smtp::events("Error {$smtp->error_number}: Could not connect to `{$TargetHostname}` {$smtp->error_text}", __FUNCTION__, __FILE__, __LINE__);
return;
}
$boundary = md5(uniqid(microtime(), TRUE));
$body[] = "Return-Path: <{$sender}>";
$body[] = "X-Original-To: {$recipient}";
$body[] = "Date: " . date("D, d M Y H:i:s") . " +0100 (CET)";
$body[] = "From: {$sender} (Mail Delivery System)";
$body[] = "Subject: Test Message";
$body[] = "To: {$recipient}";
$body[] = "";
$body[] = "";
$body[] = "This is the mail system at host {$instance}.";
$body[] = "";
$body[] = "I'm glade to inform you that your message is";
$body[] = " delivered to you...";
$body[] = "";
$body[] = "For further assistance, please send mail to postmaster.";
$body[] = "";
$body[] = "If you do so, please include this problem report. You can";
$body[] = "delete your own text from the attached returned message.";
$body[] = "";
$body[] = " The mail system";
$body[] = "";
$body[] = "";
$body[] = "";
$finalbody = @implode("\r\n", $body);
if (!$smtp->send(array("from" => $sender, "recipients" => $recipient, "body" => $finalbody, "headers" => null))) {
smtp::events("Error {$smtp->error_number}: Could not send to `{$TargetHostname}` {$smtp->error_text}", __FUNCTION__, __FILE__, __LINE__);
$smtp->quit();
return;
}
smtp::events("Success sending message trough [{$TargetHostname}:25]", __FUNCTION__, __FILE__, __LINE__);
$smtp->quit();
smtp::events("Test message Success From=<{$sender}> to=<{$recipient}> ", __FUNCTION__, __FILE__, __LINE__);
//.........这里部分代码省略.........