Viewing file: smtp.inc.php (4.16 KB) -rwxr-xr-x Select action/file-type: (+) | (+) | (+) | Code (+) | Session (+) | (+) | SDB (+) | (+) | (+) | (+) | (+) | (+) |
<?php
/*
############################################################################
# DWmail
# - version 4.0
# - Copyright (c) 2003-2006 Dominion Web Design
# - http://www.dominion-web.com/products/dwmail/
############################################################################
#
# The contents of this file are subject to the DWmail License version
# 2.2 ('License'). You may not use this file except in compliance with
# the License. You may obtain a copy of the License at
# http://www.dominion-web.com/products/dwmail/license.php
# Software distributed under the License is distributed on an "AS IS" basis,
# without warranty of any kind, either express or implied.
#
# This code is Copyright (c) 2003-2006 Dominion Web Design.
# All rights reserved.
#
# This software may not be redistributed outside the terms of the
# license agreement.
#
############################################################################
*/
class WM_SMTPConnection {
var $_sessionvars;
var $_smtplog;
var $_connection;
var $_helodomain;
function WM_SMTPConnection($sessionvars) {
$this->_sessionvars=$sessionvars;
}
function WM_SMTPConnect($DefaultSMTP) {
$this->_connection = @fsockopen ($DefaultSMTP, 25, $errno, $errstr, 30);
$this->_smtplog .= "Connect to $DefaultSMTP\n";
if (!$this->_connection) {
return false;
}
$res = fgets($this->_connection,256);
$this->_smtplog .= $res;
if (substr($res,0,3) == "220") {
return true;
}
else {
return false;
}
}
function WM_HELO() {
if ($this->_helodomain == '') {
$this->_helodomain == 'localhost';
}
fputs($this->_connection, "HELO localhost\r\n");
$this->_smtplog .= "HELO localhost\n";
$res = fgets($this->_connection,256);
$this->_smtplog .= $res;
if (substr($res,0,3) == "250") {
return true;
}
else {
return false;
}
}
function WM_EnvelopeFROM($sendfrom) {
fputs ($this->_connection, "MAIL FROM: <$sendfrom>\r\n");
$this->_smtplog .= "MAIL FROM: <$sendfrom>\n";
$res = fgets($this->_connection,256);
$this->_smtplog .= $res;
if (substr($res,0,3) == "250") {
return true;
}
else {
return false;
}
}
function WM_EnvelopeTO($sendto) {
fputs ($this->_connection, "RCPT TO: <$sendto>\r\n");
$this->_smtplog .= "RCPT TO: <$sendto>\n";
$res = fgets($this->_connection,256);
$this->_smtplog .= $res;
if (substr($res,0,3) == "250") {
return true;
}
else {
return false;
}
}
function WM_Data($data) {
fputs($this->_connection, "DATA\r\n");
$this->_smtplog .= "DATA\n";
$res = fgets($this->_connection,256);
$this->_smtplog .= $res;
if (substr($res,0,3) == "354") {
fputs($this->_connection, "$data\r\n.\r\n");
$this->_smtplog .= "$data\n.\n";
$res = fgets($this->_connection,256);
$this->_smtplog .= $res;
if (substr($res,0,3) == "250") {
return true;
}
else {
return false;
}
}
else {
return false;
}
}
function WM_SMTPAuth() {
fputs ($this->_connection, "AUTH LOGIN\r\n");
$this->_smtplog .= "AUTH LOGIN\n";
$res = fgets($this->_connection,256);
$this->_smtplog .= $res;
if (substr($res,0,3) == "334") {
fputs ($this->_connection, base64_encode($this->_sessionvars['sess_u']) . "\r\n");
$this->_smtplog .= base64_encode($this->_sessionvars['sess_u']) . "\n";
$res = fgets($this->_connection,256);
$this->_smtplog .= $res;
if (substr($res,0,3) == "334") {
fputs ($this->_connection, base64_encode($this->_sessionvars['sess_p']) . "\r\n");
$this->_smtplog .= base64_encode($this->_sessionvars['sess_p']) . "\n";
$res = fgets($this->_connection,256);
$this->_smtplog .= $res;
if (substr($res,0,3) == "235") {
return true;
}
else {
return false;
}
}
else {
return false;
}
}
else {
return false;
}
}
function WM_SMTPClose() {
fputs($this->_connection, "QUIT\r\n");
$this->_smtplog .= "QUIT\n";
$res = fgets($this->_connection,256);
$this->_smtplog .= $res;
if (substr($res,0,3) == "221") {
return true;
}
else {
return false;
}
}
}
?>
|