本文整理汇总了PHP中smtp::events方法的典型用法代码示例。如果您正苦于以下问题:PHP smtp::events方法的具体用法?PHP smtp::events怎么用?PHP smtp::events使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类smtp
的用法示例。
在下文中一共展示了smtp::events方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: archive_process_smtpsrv
function archive_process_smtpsrv($file, $realmailfrom, $realmailto)
{
$MailArchiverToSMTP = $GLOBALS["MailArchiverToSMTP"];
$MailArchiverSMTP = $GLOBALS["MailArchiverSMTP"];
$MailArchiverSMTPINcoming = $GLOBALS["MailArchiverSMTPINcoming"];
$MailArchiverSMTP_port = 25;
$SMTPSERV = true;
$realmailto = trim(strtolower($realmailto));
if ($MailArchiverSMTP == null) {
$SMTPSERV = false;
}
if ($MailArchiverSMTP == "localhost") {
$SMTPSERV = false;
}
if ($MailArchiverSMTP == "127.0.0.1") {
$SMTPSERV = false;
}
if (!$SMTPSERV) {
events("Not from=<{$realmailfrom}> to=<{$realmailto}> bad remote SMTP server `{$MailArchiverSMTP}`", __LINE__);
return true;
}
if (preg_match("#^(.+?)@(.+)#", $realmailto, $re)) {
$DomainTo = trim($re[1]);
}
if (!isset($GLOBALS["INBOUND_SMTP"])) {
$f = explode("\n", @file_get_contents("/etc/postfix/mydestination"));
while (list($num, $line) = each($f)) {
if (preg_match("#^(.+?)\\s+#", $line, $re)) {
$GLOBALS["INBOUND_SMTP"][trim(strtolower($re[1]))] = true;
}
}
$f = explode("\n", @file_get_contents("/etc/postfix/relay_domains"));
while (list($num, $line) = each($f)) {
if (preg_match("#^(.+?)\\s+#", $line, $re)) {
$GLOBALS["INBOUND_SMTP"][trim(strtolower($re[1]))] = true;
}
}
$f = explode("\n", @file_get_contents("/etc/postfix/virtual"));
while (list($num, $line) = each($f)) {
if (preg_match("#^(.+?)\\s+#", $line, $re)) {
$GLOBALS["INBOUND_SMTP"][trim(strtolower($re[1]))] = true;
}
}
}
$ISINBOUND = false;
if (isset($GLOBALS["INBOUND_SMTP"][$realmailto])) {
$ISINBOUND = true;
}
if (isset($GLOBALS["INBOUND_SMTP"][$DomainTo])) {
$ISINBOUND = true;
}
if ($MailArchiverSMTPINcoming == 1) {
if (!$ISINBOUND) {
events("Not from=<{$realmailfrom}> to=<{$realmailto}> not an inbound message", __LINE__);
return true;
}
}
if (preg_match("#^(.+?):([0-9]+)#", $MailArchiverSMTP, $re)) {
$MailArchiverSMTP = $re[1];
$MailArchiverSMTP_port = $re[2];
}
$basename = basename($file);
$smtp = new smtp();
$params["host"] = $MailArchiverSMTP;
$params["helo"] = $GLOBALS["MYHOSTNAME"];
$params["port"] = $MailArchiverSMTP_port;
//$params["bindto"]="127.0.0.1";
if (!$smtp->connect($params)) {
events("[{$basename}] {$realmailfrom} -> Could not connect to `{$MailArchiverSMTP}:{$MailArchiverSMTP_port}`", __LINE__);
smtp::events("[{$basename}] {$realmailfrom} -> Could not connect to `{$MailArchiverSMTP}:{$MailArchiverSMTP_port}`", __FUNCTION__, __FILE__, __LINE__);
return false;
}
$size = @filesize($file);
if ($size == 0) {
events("[{$basename}] Failed from=<{$realmailfrom}> to=<{$realmailto}> 0 bytes", __LINE__);
return true;
}
$MAILDATA = @file_get_contents($file);
$MAILDATA = str_replace("X-Archive-end", "X-REAL-ARCHIVED: yes", $MAILDATA);
$MAILDATA = str_replace("X-REAL-MAILFROM", "X-REAL-ARCHIVED: yes\r\nX-REAL-MAILFROM", $MAILDATA);
if (!$smtp->send(array("from" => $realmailfrom, "recipients" => $realmailto, "body" => $MAILDATA))) {
events("[{$basename}] Failed from=<{$realmailfrom}> to=<{$realmailto}>", __LINE__);
smtp::events("[{$basename}] Failed from=<{$realmailfrom}> to=<{$realmailto}>", __FUNCTION__, __FILE__, __LINE__);
return false;
}
events("Success from=<{$realmailfrom}> to=<{$realmailto}> trough {$params["host"]}", __LINE__);
if ($GLOBALS["VERBOSE"]) {
echo "Success from=<{$realmailto}> to=<{$realmailto}> trough {$params["host"]}\n";
}
return true;
}
示例2: sendEmail
function sendEmail($subject, $content = null)
{
$unix = new unix();
$hostname = "ks220503.kimsufi.com";
$mailfrom = "root@{$hostname}";
$recipient = "david@articatech.com";
$TargetHostname = "37.187.142.164";
$params["helo"] = $hostname;
$params["host"] = $TargetHostname;
$params["do_debug"] = true;
$params["debug"] = true;
$smtp = new smtp($params);
if (!$smtp->connect($params)) {
smtp::events("Error {$smtp->error_number}: Could not connect to `{$TargetHostname}` {$smtp->error_text}", __FUNCTION__, __FILE__, __LINE__);
return;
}
$random_hash = md5(date('r', time()));
$content = str_replace("\r\n", "\n", $content);
$content = str_replace("\n", "\r\n", $content);
$body[] = "Return-Path: <{$mailfrom}>";
$body[] = "Date: " . date("D, d M Y H:i:s") . " +0100 (CET)";
$body[] = "From: {$mailfrom} (robot)";
$body[] = "Subject: {$subject}";
$body[] = "To: {$recipient}";
$body[] = "";
$body[] = "";
$body[] = $content;
$body[] = "";
$finalbody = @implode("\r\n", $body);
if (!$smtp->send(array("from" => "{$mailfrom}", "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();
}
示例3: 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";
}
示例4: sendEmail
function sendEmail($subject, $content = null, $recipient)
{
$unix = new unix();
$hostname = "ks220503.kimsufi.com";
$mailfrom = "support@articatech.com";
$TargetHostname = "37.187.142.164";
$params["helo"] = $hostname;
$params["host"] = $TargetHostname;
$params["do_debug"] = true;
$params["debug"] = true;
$params["auth"] = true;
$params["user"] = "david";
$params["pass"] = "123David456Touzeau";
$smtp = new smtp($params);
if (!$smtp->connect($params)) {
smtp::events("Error {$smtp->error_number}: Could not connect to `{$TargetHostname}` {$smtp->error_text}", __FUNCTION__, __FILE__, __LINE__);
return;
}
$random_hash = md5(date('r', time()));
$boundary = "{$random_hash}/{$hostname}";
$content = str_replace("\r\n", "\n", $content);
$content = str_replace("\n", "\r\n", $content);
$body[] = "Return-Path: <{$mailfrom}>";
$body[] = "Date: " . date("D, d M Y H:i:s") . " +0100 (CET)";
$body[] = "From: {$mailfrom} (robot)";
$body[] = "Subject: {$subject}";
$body[] = "To: {$recipient}";
$body[] = "MIME-Version: 1.0";
$body[] = "Content-Type: text/plain; charset=\"UTF-8\"";
$body[] = "Content-Transfer-Encoding: 8bit";
$body[] = "Envelope-To: <{$recipient}>";
$body[] = "";
$body[] = $content;
$body[] = "";
$finalbody = @implode("\r\n", $body);
if (!$smtp->send(array("from" => "{$mailfrom}", "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();
}
示例5: 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__);
//.........这里部分代码省略.........