echo "<span class=\"error\">SMTP: 'SMTP Server' field not filled in.</span><br />"; } else { if ($_REQUEST["from"] == "") { echo "<span class=\"error\">SMTP: 'Default E-mail Address' field not filled in.</span><br />"; } else { if ($_REQUEST["to"] == "") { echo "<span class=\"error\">SMTP: 'Send To' field not filled in.</span><br />"; } } } } $pop3valid = false; if ($pop3server != "" && $_REQUEST["user"] != "" && $_REQUEST["pass"] != "") { $pop3options = array("server" => $pop3server, "port" => $pop3port, "secure" => $pop3port == 995); $temppop3 = new POP3(); $result = $temppop3->Connect($_REQUEST["user"], $_REQUEST["pass"], $pop3options); if (!$result["success"]) { echo "<span class=\"error\">Failed to connect to the POP3 server. " . htmlspecialchars($result["error"]) . (isset($result["info"]) ? " (" . htmlspecialchars($result["info"]) . ")" : "") . "</span><br />"; } else { echo "<span class=\"success\">Successfully connected to the POP3 server.</span><br />"; $temppop3->Disconnect(); $pop3valid = true; } } else { if ($pop3server == "") { echo "<span class=\"error\">POP3: 'POP3 Server' field not filled in.</span><br />"; } else { if ($_REQUEST["user"] == "") { echo "<span class=\"error\">POP3: 'Username' field not filled in.</span><br />"; } else { if ($_REQUEST["pass"] == "") {
error_reporting(E_ALL); // php errors define('DISPLAY_XPM4_ERRORS', true); // display XPM4 errors // path to 'POP3.php' and 'SMTP.php' files from XPM4 package require_once '../POP3.php'; require_once '../SMTP.php'; $f = '*****@*****.**'; // from mail address / account username $t = '*****@*****.**'; // to mail address $p = 'password'; // account password // standard mail message RFC2822 $m = 'From: ' . $f . "\r\n" . 'To: ' . $t . "\r\n" . 'Subject: test' . "\r\n" . 'Content-Type: text/plain' . "\r\n\r\n" . 'Text message.'; // connect to 'pop3.hostname.net' POP3 server address with authentication username '$f' and password '$p' $p = POP3::Connect('pop3.hostname.net', $f, $p) or die(print_r($_RESULT)); // connect to 'smtp.hostname.net' SMTP server address $c = SMTP::Connect('smtp.hostname.net') or die(print_r($_RESULT)); // send mail $s = SMTP::Send($c, array($t), $m, $f); // print result if ($s) { echo 'Sent !'; } else { print_r($_RESULT); } // disconnect from SMTP server SMTP::Disconnect($c); // disconnect from POP3 server POP3::Disconnect($p);
function SSO_SendEmail($fromaddr, $toaddr, $subject, $htmlmsg, $textmsg) { if (!class_exists("SMTP")) { define("CS_TRANSLATE_FUNC", "BB_Translate"); require_once SSO_ROOT_PATH . "/" . SSO_SUPPORT_PATH . "/smtp.php"; } $headers = SMTP::GetUserAgent("Thunderbird"); $smtpoptions = array("headers" => $headers, "htmlmessage" => $htmlmsg, "textmessage" => $textmsg, "server" => SSO_SMTP_SERVER, "port" => SSO_SMTP_PORT, "secure" => SSO_SMTP_PORT == 465, "username" => SSO_SMTPPOP3_USER, "password" => SSO_SMTPPOP3_PASS); $result = SMTP::SendEmail($fromaddr, $toaddr, $subject, $smtpoptions); if (!$result["success"] && SSO_POP3_SERVER != "") { // Try POP-before-SMTP. require_once SSO_ROOT_PATH . "/" . SSO_SUPPORT_PATH . "/pop3.php"; $pop3options = array("server" => SSO_POP3_SERVER, "port" => SSO_POP3_PORT, "secure" => SSO_POP3_PORT == 995); $temppop3 = new POP3(); $result = $temppop3->Connect(SSO_SMTPPOP3_USER, SSO_SMTPPOP3_PASS, $pop3options); if ($result["success"]) { $temppop3->Disconnect(); $result = SMTP::SendEmail($fromaddr, $toaddr, $subject, $smtpoptions); } } return $result; }