Datos contacto.

This commit is contained in:
Laegnur 2023-03-10 19:44:38 +01:00
parent b173b43124
commit f1f6b88a84
32 changed files with 14095 additions and 23 deletions

File diff suppressed because one or more lines are too long

View file

@ -0,0 +1,6 @@
[*.{php,module}]
end_of_line = LF
indent_style = space
indent_size = 4
trim_trailing_whitespace = true
insert_final_newline = true

View file

@ -0,0 +1 @@
+.module linguist-language=PHP

View file

@ -0,0 +1,96 @@
# Changelog
### 0.6.0 - 2021-04-15
- PHP 8 support
### 0.5.2 - 2020-05-25
- changed Manuel Lemos smtp-class to new version 1.52, as he added a new token feature
### 0.5.1 - 2020-05-11
- minor fix to testconnection in the configpage
### 0.5.0 - 2020-05-04
- added a verbose debug testconnection into the configpage
### 0.4.2 - 2019-05-02
- added support for connections without authentication: allow_without_authentication
### 0.4.1 - 2019-04-19
- added support for verbose debug of the connection and sending process via a new method: $mail->debugSend()
### 0.4.0 - 2019-04-19
- added support for manual selection of a crypto method for TLS per this request: https://processwire.com/talk/topic/5704-wiremailsmtp/page/12/?tab=comments#comment-184229
### 0.3.1 - 2019-03-27
- enhanced the module to get overridden by site/config settings per this request: https://processwire.com/talk/topic/5704-wiremailsmtp/page/12/?tab=comments#comment-182735
### 0.3.0 - 2017-12-08
- fixed code that broke backward compatibility for PW 2.4 and 2.5, brought in with the config cosmetics (0.2.6)
### 0.2.7 - 2017-10-19
- @abdus fixed smtp password not saving
### 0.2.6 - 2017-10-17
- module config cosmetics by @abdus, many thanks! [See this forum post](https://processwire.com/talk/topic/5704-wiremailsmtp/?page=9&tab=comments#comment-153329)
### 0.2.5 - 2017-09-12
- fixed adding HTML-signatures into HTML-messages without body-end-tag
### 0.2.4 - 2017-09-03
- updated the attachment function to silence a PHP-Strict notice
### 0.2.3 - 2016-10-08
- updated the attachment function to be conform with the new integrated function in core WireMail class (introduced with PW 3.0.36)
### 0.2.2 - 2016-05-26
- fixed date string to follow strict RFC2822, See [Issue 5](https://github.com/horst-n/WireMailSmtp/issues/5) - Many thanks to @selsermedia!
### 0.2.0 - 2016-02-15
- added support for Selfsigned Certificates, a contribution from @flydev, [See this post](https://processwire.com/talk/topic/5704-wiremailsmtp/page-5#entry113290) - Many thanks!
### 0.1.14
- changed smtp class to new version 1.50 to solve a bug with two debug messages echoed out, even if debug was set to false
### 0.1.13 - 2015-06-14
- changed default setting for wrapText from true to false.
### 0.1.12
- fixed not sending to all CC-recipients when in sendSingle mode. See [issue 3](https://github.com/horst-n/WireMailSmtp/issues/3)
### 0.1.11
- changed smtp class to new version to solve problems with mixed usage of IP and hostname, found by @k07n. See [this post](https://processwire.com/talk/topic/5704-wiremailsmtp/page-3#entry95880)
### 0.1.10
- made wrapText configurable by Jan Romero [Commit abc0ac0b](https://github.com/horst-n/WireMailSmtp/commit/abc0ac0b4a3edd0fcbbb8b4695f00a362705ad5b)
### 0.1.9
- disabling connecting without authentication in the smtp base class
### 0.1.8
- added a separate inputfield for a HTML signature into config page
### 0.1.7
- set status from alpha to beta
### 0.0.7
- added new sentLog methods for permanent logging, intended for usage with third party modules, e.g. newsletter modules
### 0.0.6
- corrected addSignature to check and respect the config screen setting
### 0.0.5
- added multiple emails sending and bulkmail sending
### 0.0.4
- changed the functions "to" "cc" "bcc" to be compatible with Ryans changes
### 0.0.3
- added GMT Timezone to the Dateheader to reflect local timezones and show DateTime correct in Mailclients
### 0.0.2
- added sanitization to recipient names in email addresses (in file: WireMailSmtp.module)
### 0.0.1
- initial release
More information and code examples, please visit the [WireMailSmtp ProcessWire forum thread.](http://processwire.com/talk/topic/5704-module-wiremailsmtp/)

View file

@ -0,0 +1,84 @@
WireMailSmtp
============
### ProcessWire: a extension to the WireMail base class that uses SMTP-transport ###
### Only functional with ProcessWire Version 2.4.1 or greater ###
This module integrates EmailMessage, SMTP and SASL php-libraries from [Manuel Lemos](http://www.phpclasses.org/browse/author/1.html) into ProcessWire.
[More information and code examples](http://processwire.com/talk/topic/5704-module-wiremailsmtp/)
---
### Current Version 0.6.0 ###
### List of all options and features ###
**testConnection** () *- returns true on success, false on failures*
**debugSend** () *- send the mail(s) and output or return verbose messages of the complete connection and sending process*
**sendSingle** ( true | false ) *- default is false*
**sendBulk** ( true | false ) *- default is false, Set this to true if you have lots of recipients (50+)*
**to** ($recipients) *- one emailaddress or array with multiple emailaddresses*
**cc** ($recipients) *- only available with mode sendSingle, one emailaddress or array with multiple emailaddresses*
**bcc** ($recipients) *- one emailaddress or array with multiple emailaddresses*
**from** = 'person@example.com' *- can be set in module config (called Sender Emailaddress) but it can be overwritten here*
**fromName =** 'Name Surname' *- optional, can be set in module config (called Sender Name) but it can be overwritten here*
**priority** (3) *- 1 = Highest | 2 = High | 3 = Normal | 4 = Low | 5 = Lowest*
**dispositionNotification** () or **notification** () *- request a Disposition Notification*
**subject** ($subject) *- subject of the message*
**body** ($textBody) *- use this one alone to create and send plainText emailmessages*
**bodyHTML** ($htmlBody) *- use this to create a Multipart Alternative Emailmessage (containing a HTML-Part and a Plaintext-Part as fallback)*
**addSignature** ( true | false ) *- the default-behave is selectable in config screen, this can be overridden here. (only available if a signature is defined in the config screen)*
**attachment** ($filename, $alternativeBasename = '') *- add attachment file*
**send** () *- send the mail(s) and return number of successful send messages*
**getResult** () *- returns a dump (array) with all recipients (to, cc, bcc) and settings you have selected with the message, the message subject and body, and lists of successfull addresses and failed addresses,*
**logActivity** ($logmessage) *- you may log success if you want*
**logError** ($logmessage) *- you may log errors, too. - Errors are also logged automaticaly*
**useSentLog** (true | false) *- intended for usage with e.g. third party newsletter modules - tells the send() method to make usage of the sentLog-methods*
**sentLogReset** () *- starts a new Session. Best usage would be interactively once when setting up a new Newsletter*
**sentLogGet** () *- returns an array containing all previously used emailaddresses*
**sentLogAdd** ($emailaddress) *- is called automaticly within the send() method*
**wrapText** (true|false) *- default is true*
[More information and code examples](http://processwire.com/talk/topic/5704-module-wiremailsmtp/)

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,448 @@
<?php
/*******************************************************************************
* WireMailSmtp | hnsmtp
*
* @version - '0.6.0'
* @date - 2021/04/15
* @author - Horst Nogajski
* @licence - GNU GPL v2 - http://www.gnu.org/licenses/gpl-2.0.html
* @licence - MIT - https://processwire.com/about/license/mit/
********************************************************************************/
require_once( dirname(__FILE__) . '/smtp_classes/email_message.php' );
require_once( dirname(__FILE__) . '/smtp_classes/smtp_message.php' );
require_once( dirname(__FILE__) . '/smtp_classes/smtp.php' );
require_once( dirname(__FILE__) . '/smtp_classes/sasl.php' );
class hnsmtp {
private $default_charset = 'UTF-8';
private $smtp_host = ''; /* SMTP server host name */
private $smtp_port = 25; /* SMTP server host port,
usually 25 but for use with SSL or TLS 587 */
private $smtp_ssl = 0; /* Establish secure connections using SSL */
private $smtp_ssl_crypto_method = ''; /* Define the crypto method to use with SSL */
private $smtp_start_tls = 0; /* Establish secure connections using START_TLS */
private $smtp_tls_crypto_method = ''; /* Define the crypto method to use with TLS */
private $localhost = ''; /* this computers address */
private $realm = ''; /* Authentication realm or domain */
private $workstation = ''; /* Workstation for NTLM authentication */
private $authentication_mechanism = ''; /* SASL authentication mechanism */
private $allow_without_authentication = 0; /* Server allows connection without authentication */
private $smtp_user = ''; /* Authentication user name */
private $smtp_password = ''; /* Authentication password */
private $smtp_debug = 0; /* Output debug information */
private $smtp_html_debug = 0; /* Debug information is in HTML */
private $sender_name = ''; // From: the senders name
private $sender_email = ''; // From: the senders email address
private $sender_reply = ''; // Reply-To: optional email address
private $sender_errors_to = ''; // Errors-To: optional email address
private $sender_signature = ''; // a Signature Text, like Contact Data and / or Confidentiality Notices
private $sender_signature_html = ''; // a Signature Text in HTML, like Contact Data and / or Confidentiality Notices
private $send_sender_signature = 1; // when the signature should be send: with every mail | only when the default Email is the sender | only when explicitly called via the API
private $extra_headers = array(); // optional Custom-Meta-Headers
private $valid_recipients = array(); /* SenderEmailAddresses wich are allowed to
receive Messages */
private $smtp_certificate = false; // @flydev: https://processwire.com/talk/topic/5704-wiremailsmtp/page-5#entry113290
private $aValidVars = null;
private $emailMessage = null;
private $connected = null;
private $errors = array();
private $from = '';
private $fromName = '';
public function testConnection($debug = false) {
$res = $this->connect($debug);
$this->close();
return $res;
}
public function connect($debug = false) {
$this->connected = (($this->errors[] = $this->emailMessage->StartSendingMessage()) == '') ? true : false;
return $this->connected;
}
public function close() {
if(!isset($this->emailMessage)) {
return null;
}
$res = $this->emailMessage->ResetConnection('') == '' ? true : false;
$this->connected = false;
return $res;
}
public function getErrors() {
$a = array();
foreach( $this->errors as $e ) {
if($e=='') {
continue;
}
$a[] = $e;
}
$this->errors = $a;
return $this->errors;
}
protected function set_var_val( $k, $v ) {
if(!isset($this->aValidVars[$k])) {
return;
}
switch($k) {
case 'send_sender_signature':
case 'smtp_port':
$this->$k = intval($v);
break;
case 'smtp_certificate':
case 'smtp_ssl':
case 'smtp_start_tls':
case 'smtp_debug':
case 'smtp_html_debug':
case 'allow_without_authentication':
if(is_bool($v)) {
$this->$k = $v==true ? 1 : 0;
}
elseif(is_int($v)) {
$this->$k = $v==1 ? 1 : 0;
}
elseif(is_string($v) && in_array($v, array('1','on','On','ON','true','TRUE'))) {
$this->$k = 1;
}
elseif(is_string($v) && in_array($v, array('0','off','Off','OFF','false','FALSE'))) {
$this->$k = 0;
}
else {
$this->$k = 0;
}
break;
case 'smtp_tls_crypto_method':
$availableTLSmethods = WireMailSmtp::getCryptoMethodsTLS();
if(is_string($v) && isset($v, $availableTLSmethods)) {
$this->$k = $v;
}
break;
case 'smtp_ssl_crypto_method':
$availableSSLmethods = WireMailSmtp::getCryptoMethodsSSL();
if(is_string($v) && isset($v, $availableSSLmethods)) {
$this->$k = $v;
}
break;
case 'authentication_mechanism':
$this->authentication_mechanism = $v;
break;
case 'valid_recipients':
case 'extra_headers';
$this->$k = is_array($v) || is_string($v) ? (array)$v : array();
break;
default:
if(in_array($k, array('smtp_host', 'smtp_user', 'smtp_password',
'localhost', 'workstation', 'realm',
'sender_name', 'sender_email', 'sender_reply',
'sender_errors_to', 'sender_signature', 'sender_signature_html',
'default_charset'
))
) {
$this->$k = strval($v);
}
}
}
public function __construct($aConfig = null) {
if(!is_array($aConfig)) {
return;
}
$this->aValidVars = get_class_vars(__CLASS__);
foreach($aConfig as $k => $v) {
$this->set_var_val($k, $v);
}
foreach($this->valid_recipients as $k=>$v) {
$this->valid_recipients[$k] = str_replace(array('<','>'), '', strtolower(trim($v)));
}
// start SMTP-Mail
$this->emailMessage = new smtp_message_class();
// SMTP Server Authentication
$this->emailMessage->default_charset = $this->default_charset;
$this->emailMessage->localhost = $this->localhost;
$this->emailMessage->smtp_host = $this->smtp_host;
$this->emailMessage->smtp_port = $this->smtp_port;
$this->emailMessage->smtp_ssl = $this->smtp_ssl;
$this->emailMessage->smtp_ssl_crypto_method = $this->smtp_ssl_crypto_method;
$this->emailMessage->smtp_start_tls = $this->smtp_start_tls;
$this->emailMessage->smtp_tls_crypto_method = $this->smtp_tls_crypto_method;
$this->emailMessage->smtp_user = $this->smtp_user;
$this->emailMessage->smtp_password = $this->smtp_password;
$this->emailMessage->allow_without_authentication = $this->allow_without_authentication;
$this->emailMessage->smtp_certificate = $this->smtp_certificate;
// advanced SMTP Server Settings
$this->emailMessage->realm = $this->realm;
$this->emailMessage->workstation = $this->workstation;
$this->emailMessage->authentication_mechanism = $this->authentication_mechanism;
// Debug on / off
$this->emailMessage->smtp_debug = $this->smtp_debug;
$this->emailMessage->smtp_html_debug = $this->smtp_html_debug;
}
public function __destruct() {
if( $this->connected ) {
$this->close();
}
unset($this->emailMessage);
}
protected function logError($msg) {
if(!isset($this->module)) $this->module = wire('modules')->get('WireMailSmtp');
$this->module->logError($msg);
}
protected function logActivity($msg) {
if(!isset($this->module)) $this->module = wire('modules')->get('WireMailSmtp');
$this->module->logActivity($msg);
}
public function setSender($from='', $fromName='') {
$genericEmail = isset($this->localhost) ? 'processwire@' . $this->localhost : false;
$sender = strlen($from)>0 ? $from : $this->sender_email;
if(empty($sender) && false!==$genericEmail) {
$sender = $genericEmail; // fallback to a generic email address
}
$this->isValidEmailadress($sender); // if it is not a valid Emailaddress a Error is thrown
$senderName = strlen($fromName)>0 ? $fromName : $this->sender_name;
$this->from = $sender;
$this->fromName = $senderName;
if($sender==$this->sender_email) {
// we use the defaults from module config
$replyTo = isset($this->sender_reply) && strlen($this->sender_reply)>0 ? $this->sender_reply : $this->sender_email;
$errorsTo = isset($this->sender_errors_to) && strlen($this->sender_errors_to)>0 ? $this->sender_errors_to : $this->sender_email;
}
else {
$replyTo = $genericEmail!=$sender ? $sender : ''; // we don't want get replys to the generic emailaddress
$errorsTo = '';
}
$this->setEmailHeader('from', $sender, $senderName);
if(''!=$replyTo) $this->setEmailHeader('reply', $replyTo);
if(''!=$errorsTo) $this->setEmailHeader('errors', $errorsTo);
}
public function setCustomHeader($header) {
$extra_headers = (isset($this->extra_headers) && is_array($this->extra_headers) && 0<count($this->extra_headers)) ? $this->extra_headers : array();
$headers = array_merge($extra_headers, $header);
foreach($headers as $k=>$v) {
$this->setHeader($k, $v);
}
}
public function setTextBody($text, $addSignature, $wrapText, &$maildata) {
if($addSignature===true && isset($this->sender_signature) && is_string($this->sender_signature) && strlen(trim($this->sender_signature))>0) {
$text .= "\r\n\r\n" . $this->sender_signature;
}
$text = $wrapText ? $this->emailMessage->WrapText($text) : (string)$text;
$maildata = $text;
$ret = $this->emailMessage->AddQuotedPrintableTextPart($text);
if($ret=='') {
return true;
}
$this->logError('Error in '.__CLASS__.'::'.__FUNCTION__.' : ' . $ret);
return false;
}
public function setTextAndHtmlBody($text, $html, $addSignature, $wrapText, &$maildata1, &$maildata2) {
if($addSignature===true && isset($this->sender_signature) && is_string($this->sender_signature) && strlen(trim($this->sender_signature))>0) {
$text .= "\r\n\r\n--\r\n" . $this->sender_signature;
}
if($addSignature===true && isset($this->sender_signature_html) && is_string($this->sender_signature_html) && strlen(trim($this->sender_signature_html))>0) {
// we first need to check if there is a </body> end tag in the html-markup
if(preg_match('</body>', $html)) {
$html = str_replace("</body>", "\r\n\r\n" . $this->sender_signature_html . "\r\n</body>", $html);
} else {
$html .= "\r\n\r\n" . $this->sender_signature_html . "\r\n";
}
}
$maildata1 = $text = $wrapText ? $this->emailMessage->WrapText($text) : (string)$text;
$maildata2 = $html = $wrapText ? $this->emailMessage->WrapText($html) : (string)$html;
// create Alternative-Multipart
$html_part = $text_part = $alternative_part = 0;
$this->emailMessage->CreateQuotedPrintableTextPart($text, 'UTF-8', $text_part);
$this->emailMessage->CreateQuotedPrintableHTMLPart($html, 'UTF-8', $html_part);
$alternative_parts = array( $text_part, $html_part );
#$this->emailMessage->CreateAlternativeMultipart($alternative_parts, $alternative_part);
$ret = $this->emailMessage->AddAlternativeMultipart($alternative_parts);
if($ret=='') {
return true;
}
$this->logError('Error in '.__CLASS__.'::'.__FUNCTION__.' : ' . $ret);
return false;
}
public function addAttachment($attachment) {
$ret = $this->emailMessage->AddFilePart($attachment);
if($ret=='') {
return true;
}
$this->logError('Error in '.__CLASS__.'::'.__FUNCTION__.' : ' . $ret);
return false;
}
public function setNotification(&$maildata) {
if(!isset($this->from) || strlen(trim($this->from))==0) {
return false;
}
$email = $this->bundleEmailAndName($this->from, $this->fromName);
$maildata = $email;
return $this->setHeader('Disposition-Notification-To', $email);
}
public function setPriority($priority=3) {
$priority = intval($priority);
if(!in_array($priority, array(1, 2, 3, 4, 5))) {
$this->logError('Error in '.__CLASS__.'::'.__FUNCTION__.' : ' . "($priority)");
return false;
}
$priorities = array(
5 => array('5 (Lowest)', 'Low', 'Low'),
4 => array('4 (Low)', 'Low', 'Low'),
3 => array('3 (Normal)', 'Normal', 'Normal'),
2 => array('2 (High)', 'High', 'High'),
1 => array('1 (Highest)', 'High', 'High')
);
$ret = 0;
$ret += $this->setHeader('X-Priority', $priorities[$priority][0]) ? 1 : 0;
$ret += $this->setHeader('X-MSMail-Priority', $priorities[$priority][1]) ? 1 : 0;
$ret += $this->setHeader('Importance', $priorities[$priority][2]) ? 1 : 0;
return 3==$ret ? true : false;
}
public function send($debugServer=false, $htmlDebug=false, &$maildata='') {
if($debugServer) $this->emailMessage->smtp_debug = 1;
if($htmlDebug) $this->emailMessage->smtp_html_debug = 1;
if(!$this->connect()) {
$this->logError('Error in '.__CLASS__.'::'.__FUNCTION__.' : cannot connect to smtp-server!');
return false;
}
$this->emailMessage->SetHeader("Date", gmdate("D, j M Y H:i:s \G\M\T"));
$ret = $this->emailMessage->Send();
if($ret=='') {
$maildata = 'success';
return true;
}
$this->logError('Error in '.__CLASS__.'::'.__FUNCTION__.' : ' . $ret);
$maildata = (string)$ret;
return false;
}
public function setEmailHeader($type, $address, $name='') {
$address = str_replace(array('<','>'), '', $address);
if(!$this->isValidEmailadress($address)) {
$this->logError('Error in '.__CLASS__.'::'.__FUNCTION__.' : No valid E-mailadress: '.$address);
return false;
}
$type = strtolower($type);
$valid_types = array('to'=>'To','from'=>'From','cc'=>'CC','bcc'=>'BCC','reply-to'=>'Reply-To','reply'=>'Reply-To','errors-to'=>'Errors-To','errors'=>'Errors-To','error'=>'Errors-To');
if(!in_array($type,array_keys($valid_types))) {
$this->logError('Error in '.__CLASS__.'::'.__FUNCTION__.' : No valid Headertype: '.$type);
return false;
}
if(strpos($type,'reply')!==false) {
$this->emailMessage->SetHeader('Return-Path',$address);
}
$ret = $this->emailMessage->SetEncodedEmailHeader($valid_types[$type], $address, $name);
if($ret!='') {
$this->logError('Error in '.__CLASS__.'::'.__FUNCTION__.' : ' . $ret);
return false;
}
return true;
}
public function setHeader($headername,$content) {
$ret = $this->emailMessage->SetEncodedHeader($headername,$content);
if($ret!='') {
$this->logError('Error in '.__CLASS__.'::'.__FUNCTION__.' : ' . $ret);
return false;
}
return true;
}
public function isValidEmailadress($email) {
$email = strtolower(trim($email));
$clean = wire('sanitizer')->email($email);
if($email != $clean) throw new WireException("Invalid email address");
return true;
}
protected function bundleEmailAndName($email, $name) {
$email = strtolower(trim($email));
$clean = wire('sanitizer')->email($email);
if(!strlen($name)) return $email;
$name = wire('sanitizer')->emailHeader($name);
if(strpos($name, ',') !== false) {
// name contains a comma, so quote the value
$name = str_replace('"', '', $name); // remove existing quotes
$name = '"' . $name . '"'; // surround w/quotes
}
return "$name <$email>";
}
public function setBulkMail($bulk) {
return $this->emailMessage->setBulkMail($bulk);
}
} // END class hnsmtp

View file

@ -0,0 +1,641 @@
<?php
/*******************************************************************************
* WireMailSmtp | WireMailSmtpConfig
* ---------------------------------------------------------------------------
* @version - '0.6.0'
* @author - Horst Nogajski
* @licence - GNU GPL v2 - http://www.gnu.org/licenses/gpl-2.0.html
*******************************************************************************/
class WireMailSmtpConfig extends Wire {
public function getConfig(array $data) {
// check that they have the required PW version
if(version_compare(wire('config')->version, '2.4.1', '<')) {
$this->error(' requires ProcessWire 2.4.1 or newer. Please update.');
}
$siteconfig = is_array(wire('config')->wiremailsmtp) ? wire('config')->wiremailsmtp : array();
$modules = wire('modules');
$form = new InputfieldWrapper();
// LOCALHOST
$field = $modules->get('InputfieldText');
$field->attr('name', 'localhost');
$field->attr('value', $data['localhost']);
$field->label = $this->_('Local Hostname');
$field->description = $this->_('Hostname of this computer');
if(isset($siteconfig['localhost'])) {
$field->notes = $this->attentionMessage($siteconfig['localhost']);
$field->attr('tabindex', '-1');
} else {
$field->required = true;
}
$field->icon = 'desktop';
$form->add($field);
// WRAPPER SMTP SERVER
$fieldset = $modules->get('InputfieldFieldset');
$fieldset->label = $this->_('SMTP Server');
$fieldset->attr('name', '_smtp');
$fieldset->collapsed = Inputfield::collapsedNo;
$fieldset->icon = 'server';
// SMTP HOST
$field = $modules->get('InputfieldText');
$field->attr('name', 'smtp_host');
$field->attr('value', $data['smtp_host']);
$field->label = $this->_('SMTP Hostname');
$field->description = $this->_('Set to the host name of the SMTP server to which you want to relay the messages');
$field->columnWidth = 50;
if(isset($siteconfig['smtp_host'])) {
$field->notes = $this->attentionMessage($siteconfig['smtp_host']);
$field->attr('tabindex', '-1');
} else {
$field->required = true;
}
$field->icon = 'server';
$fieldset->add($field);
// SMTP PORT
$field = $modules->get('InputfieldInteger');
$field->attr('name', 'smtp_port');
$field->attr('value', $data['smtp_port']);
$field->label = $this->_('SMTP Port');
$field->description = $this->_('Set to the TCP port of the SMTP server host to connect');
if(isset($siteconfig['smtp_port'])) {
$field->notes = $this->attentionMessage($siteconfig['smtp_port']);
$field->attr('tabindex', '-1');
} else {
$field->notes = $this->_("default: 25\ndefault for TLS / SSL: 587 or 465");
$field->required = true;
}
$field->columnWidth = 50;
$field->icon = 'sign-out';
$fieldset->add($field);
// ALLOW WITHOUT ANY AUTHENTICATION
$field = $modules->get('InputfieldCheckbox');
$field->attr('name', 'allow_without_authentication');
$field->attr('id', 'allow_without_authentication');
$field->attr('value', 1);
$field->attr('checked', $data['allow_without_authentication'] ? 'checked' : '');
$field->label = $this->_('Allow Connection without Authentication');
$field->description = $this->_('Server allows connecting without Authentication Credentials');
if(isset($siteconfig['allow_without_authentication'])) {
$field->notes = $this->attentionMessage($siteconfig['allow_without_authentication']);
$field->attr('tabindex', '-1');
} else {
$field->notes = $this->_('Default: unchecked');
}
$field->columnWidth = 33;
$field->icon = 'unlock';
$fieldset->add($field);
// SMTP USER
$field = $modules->get('InputfieldText');
$field->attr('name', 'smtp_user');
$field->attr('value', $data['smtp_user']);
$field->label = $this->_('SMTP User');
$field->description = $this->_('Set this variable to the user name when the SMTP server requires authentication');
if(isset($siteconfig['smtp_user'])) {
$field->notes = $this->attentionMessage($siteconfig['smtp_user']);
$field->attr('tabindex', '-1');
}
$field->columnWidth = 34;
$field->icon = 'user';
$fieldset->add($field);
// SMTP PASSWORD
$field = $modules->get('InputfieldText');
$field->attr('name', 'smtp_password');
$field->attr('value', $data['smtp_password']);
$field->attr('type', 'password');
$field->label = $this->_('SMTP Password');
$field->description = $this->_('Set this variable to the user password when the SMTP server requires authentication');
if(isset($siteconfig['smtp_password'])) {
$field->notes = $this->attentionMessage('*******');
$field->attr('tabindex', '-1');
} else {
$field->notes = $this->_('**Note**: Password is stored as plain text in database.');
}
$field->columnWidth = 33;
$field->icon = 'asterisk';
$fieldset->add($field);
// SMTP STARTTLS
$field = $modules->get('InputfieldCheckbox');
$field->attr('name', 'smtp_start_tls');
$field->attr('id', 'smtp_start_tls');
$field->attr('value', 1);
$field->attr('checked', $data['smtp_start_tls'] ? 'checked' : '');
$field->columnWidth = 50;
$field->label = $this->_('Use START-TLS');
$field->description = $this->_('Check if the connection to the SMTP server should use encryption after the connection is established using TLS protocol');
if(isset($siteconfig['smtp_start_tls'])) {
$field->notes = $this->attentionMessage($siteconfig['smtp_start_tls']);
$field->attr('tabindex', '-1');
}
$field->icon = 'lock';
//$field->showIf = 'smtp_ssl=0';
$fieldset->add($field);
// TLS crypto method
$field = $modules->get('InputfieldSelect');
$field->attr('name', 'smtp_tls_crypto_method');
$field->attr('value', $data['smtp_tls_crypto_method']);
$field->label = $this->_('Select a crypto method for TLS');
$availableTLSmethods = WireMailSmtp::getCryptoMethodsTLS();
array_unshift($availableTLSmethods, array(''));
$field->addOptions($availableTLSmethods);
$field->description = $this->_("Select the crypto method that should be used for TLS connections. If you don't know what to select, try with the highest and strongest entry first!");
if(isset($siteconfig['smtp_tls_crypto_method'])) {
$field->notes = $this->attentionMessage($siteconfig['smtp_tls_crypto_method']);
$field->attr('tabindex', '-1');
}
$field->columnWidth = 50;
$field->icon = 'lock';
//$field->showIf = 'smtp_start_tls=1';
$fieldset->add($field);
// SMTP SSL
$field = $modules->get('InputfieldCheckbox');
$field->attr('name', 'smtp_ssl');
$field->attr('id', 'smtp_ssl');
$field->attr('value', 1);
$field->attr('checked', $data['smtp_ssl'] ? 'checked' : '');
$field->columnWidth = 100;
$field->label = $this->_('Use SSL');
$field->description = $this->_('Check if the SMTP server requires secure connections using SSL protocol');
if(isset($siteconfig['smtp_ssl'])) {
$field->notes = $this->attentionMessage($siteconfig['smtp_ssl']);
$field->attr('tabindex', '-1');
}
$field->icon = 'lock';
//$field->showIf = 'smtp_start_tls=0';
$fieldset->add($field);
// SSL crypto method
// $field = $modules->get('InputfieldSelect');
// $field->attr('name', 'smtp_ssl_crypto_method');
// $field->attr('value', $data['smtp_ssl_crypto_method']);
// $field->label = $this->_('Select a crypto method for SSL');
// $availableSSLmethods = WireMailSmtp::getCryptoMethodsSSL();
// array_unshift($availableSSLmethods, array(''));
// $field->addOptions($availableSSLmethods);
// $field->description = $this->_("Select the crypto method that should be used for SSL connections. If you don't know what to select, try with the highest and strongest entry first!");
// if(isset($siteconfig['smtp_ssl_crypto_method'])) {
// $field->notes = $this->attentionMessage($siteconfig['smtp_ssl_crypto_method']);
// $field->attr('tabindex', '-1');
// }
// $field->columnWidth = 50;
// $field->icon = 'lock';
// $fieldset->add($field);
// SMTP CERTIFICATE
// @flydev: https://processwire.com/talk/topic/5704-wiremailsmtp/page-5#entry113290
if(version_compare(phpversion(), '5.6.0', '>=')) {
$field = $modules->get('InputfieldCheckbox');
$field->attr('name', 'smtp_certificate');
$field->label = $this->_('PHP >= 5.6 - Allow self signed certificate');
$field->attr('value', $data['smtp_certificate']);
$field->attr('checked', $data['smtp_certificate'] ? 'checked' : '');
$field->columnWidth = 100;
$field->icon = 'certificate';
$fieldset->add($field);
}
// WRAPPER ADVANCED SMTP SETTINGS
$fieldset2 = $modules->get('InputfieldFieldset');
$fieldset2->label = $this->_('Advanced SMTP');
$fieldset2->attr('name', '_advanced_SMTP');
$fieldset2->collapsed = Inputfield::collapsedYes;
$fieldset2->icon = 'cogs';
// AUTHENTICATION MECHANISM
$field = $modules->get('InputfieldText');
$field->attr('name', 'authentication_mechanism');
$field->attr('value', $data['authentication_mechanism']);
$field->label = $this->_('Authentication Mechanism');
$field->description = $this->_('Force the use of a specific authentication mechanism.');
if(isset($siteconfig['authentication_mechanism'])) {
$field->notes = $this->attentionMessage($siteconfig['authentication_mechanism']);
$field->attr('tabindex', '-1');
} else {
$field->notes = $this->_('Default: empty');
}
$field->columnWidth = 33;
$field->icon = 'unlock';
$fieldset2->add($field);
// REALM
$field = $modules->get('InputfieldText');
$field->attr('name', 'realm');
$field->attr('value', $data['realm']);
$field->label = $this->_('Realm');
$field->description = $this->_('Set this variable when the SMTP server requires authentication and if more than one authentication realm is supported');
if(isset($siteconfig['realm'])) {
$field->notes = $this->attentionMessage($siteconfig['realm']);
$field->attr('tabindex', '-1');
} else {
$field->notes = $this->_('Default: empty');
}
$field->columnWidth = 34;
$field->icon = 'map-signs';
$fieldset2->add($field);
// WORKSTATION
$field = $modules->get('InputfieldText');
$field->attr('name', 'workstation');
$field->attr('value', $data['workstation']);
$field->label = $this->_('Workstation');
$field->description = $this->_('Set this variable to the client workstation when the SMTP server requires authentication identifiying the origin workstation name');
if(isset($siteconfig['workstation'])) {
$field->notes = $this->attentionMessage($siteconfig['workstation']);
$field->attr('tabindex', '-1');
} else {
$field->notes = $this->_('Default: empty');
}
$field->columnWidth = 33;
$field->icon = 'building';
$fieldset2->add($field);
$fieldset->add($fieldset2);
$form->add($fieldset);
// WRAPPER SENDER
$fieldset = $modules->get('InputfieldFieldset');
$fieldset->label = $this->_('Sender');
$fieldset->attr('name', '_sender');
$fieldset->collapsed = Inputfield::collapsedNo;
$fieldset->icon = 'address-book';
// SENDER EMAIL
$field = $modules->get('InputfieldText');
$field->attr('name', 'sender_email');
$field->attr('value', $data['sender_email']);
$field->label = $this->_('Sender Email Address');
if(isset($siteconfig['sender_email'])) {
$field->notes = $this->attentionMessage($siteconfig['sender_email']);
$field->attr('tabindex', '-1');
}
$field->columnWidth = 50;
$field->icon = 'at';
$fieldset->add($field);
// SENDER NAME
$field = $modules->get('InputfieldText');
$field->attr('name', 'sender_name');
$field->attr('value', $data['sender_name']);
$field->label = $this->_('Sender Name');
if(isset($siteconfig['sender_name'])) {
$field->notes = $this->attentionMessage($siteconfig['sender_name']);
$field->attr('tabindex', '-1');
}
$field->columnWidth = 50;
$field->icon = 'user';
$fieldset->add($field);
// SENDER REPLY EMAIL
$field = $modules->get('InputfieldText');
$field->attr('name', 'sender_reply');
$field->attr('value', $data['sender_reply']);
$field->label = $this->_('Reply Email Address');
$field->description = $this->_('if is empty, Sender Emailaddress is used');
if(isset($siteconfig['sender_reply'])) {
$field->notes = $this->attentionMessage($siteconfig['sender_reply']);
$field->attr('tabindex', '-1');
}
$field->columnWidth = 50;
$field->collapsed = Inputfield::collapsedYes;
$field->icon = 'mail-reply';
$fieldset->add($field);
// SENDER ERROR EMAIL
$field = $modules->get('InputfieldText');
$field->attr('name', 'sender_errors_to');
$field->attr('value', $data['sender_errors_to']);
$field->label = $this->_('Errors Email Address');
if(isset($siteconfig['sender_errors_to'])) {
$field->notes = $this->attentionMessage($siteconfig['sender_errors_to']);
$field->attr('tabindex', '-1');
} else {
$field->notes = $this->_('Default: empty');
}
$field->columnWidth = 50;
$field->collapsed = Inputfield::collapsedYes;
$field->icon = 'remove';
$fieldset->add($field);
// SENDER SIGNATURE (TEXT)
$field = $modules->get('InputfieldTextarea');
$field->attr('name', 'sender_signature');
$field->attr('value', $data['sender_signature']);
$field->label = $this->_('Sender Signature (Plain Text)');
$field->description = $this->_('Like Contact Data and / or Confidentiality Notices');
if(isset($siteconfig['sender_signature'])) {
$field->notes = $this->attentionMessage('***');
$field->attr('tabindex', '-1');
}
$field->columnWidth = 33;
$field->icon = 'pencil';
$fieldset->add($field);
// SENDER SIGNATURE (HTML)
$field = $modules->get('InputfieldTextarea');
$field->attr('name', 'sender_signature_html');
$field->attr('value', $data['sender_signature_html']);
$field->label = $this->_('Sender Signature (HTML)');
$field->description = $this->_('Like Contact Data and / or Confidentiality Notices');
if(isset($siteconfig['sender_signature_html'])) {
$field->notes = $this->attentionMessage('***');
$field->attr('tabindex', '-1');
}
$field->columnWidth = 33;
$field->icon = 'code';
$fieldset->add($field);
// SENDER SEND SIGNATURE
$field = $modules->get('InputfieldSelect');
$field->attr('name', 'send_sender_signature');
$field->attr('value', $data['send_sender_signature']);
$field->label = $this->_('Send Sender Signature');
$field->addOptions(array(
'1' => 'only when explicitly called via API',
'2' => 'automaticaly when FROM = Sender Emailaddress',
'3' => 'automaticaly with _every_ Message'
));
$field->description = $this->_('When the Signature should be send by default, (could be overriden by the API)');
$field->columnWidth = 34;
$field->icon = 'question';
$fieldset->add($field);
$form->add($fieldset);
// WRAPPER ADVANCED SETTINGS
$fieldset = $modules->get('InputfieldFieldset');
$fieldset->label = $this->_('Advanced');
$fieldset->attr('name', '_advanced');
$fieldset->collapsed = Inputfield::collapsedYes;
$fieldset->icon = 'gear';
// VALID RECIPIENTS
$field = $modules->get('InputfieldTextarea');
$field->attr('name', 'valid_recipients');
$field->attr('value', $data['valid_recipients']);
$field->label = $this->_('Valid Recipients');
$field->description = $this->_('List of email addresses that can receive messages.');
if(isset($siteconfig['valid_recipients'])) {
$aTemp = array();
foreach($siteconfig['valid_recipients'] as $k => $v) $aTemp[] = "{$k} : {$v}";
$field->notes = $this->attentionMessage("\n" . implode("\n", $aTemp) . "\n");
$field->attr('tabindex', '-1');
unset($k, $v, $aTemp);
} else {
$field->notes = $this->_('One email per line');
}
$field->columnWidth = 50;
$field->icon = 'users';
$fieldset->add($field);
// EXTRA HEADERS
$field = $modules->get('InputfieldTextarea');
$field->attr('name', 'extra_headers');
$field->attr('value', $data['extra_headers']);
$field->label = $this->_('Extra Headers');
$field->description = $this->_('Optionally define custom meta headers.');
if(isset($siteconfig['extra_headers'])) {
$aTemp = array();
foreach($siteconfig['extra_headers'] as $k => $v) $aTemp[] = "{$k} : {$v}";
$field->notes = $this->attentionMessage("\n" . implode("\n", $aTemp) . "\n");
$field->attr('tabindex', '-1');
unset($k, $v, $aTemp);
} else {
$field->notes = $this->_('One email per line');
}
$field->columnWidth = 50;
$field->icon = 'align-left';
$fieldset->add($field);
$form->add($fieldset);
// DISPLAY FINAL MERGED SETTINGS
$field = $modules->get('InputfieldMarkup');
$field->attr('name', '_final_settings');
$field->label = 'Final Merged Settings';
$field->icon = 'filter';
$field->columnWidth = 100;
$field->collapsed = Inputfield::collapsedNo;
$field->attr('value', $this->finalSettingsMessage($siteconfig));
$form->add($field);
// TEST SETTINGS
$field = $modules->get('InputfieldCheckbox');
$field->attr('name', '_test_settings');
$field->label = $this->_('Test settings');
$field->description = $this->_('Test settings now.');
$field->attr('value', 1);
$field->attr('checked', '');
$field->icon = 'heartbeat';
$form->add($field);
// OPTIONAL VERBOSE DEBUGGING
$fieldset = $modules->get('InputfieldFieldset');
$fieldset->label = $this->_('Verbose Debug settings');
$fieldset->attr('name', '_verbosedebug');
$fieldset->collapsed = Inputfield::collapsedNo;
$fieldset->showIf = '_test_settings=1';
$fieldset->icon = 'heartbeat';
$field = $modules->get('InputfieldText');
$field->attr('name', 'debug_senderemail');
$field->attr('value', $data['sender_email']);
$field->label = $this->_('Sender Email Address');
// if(isset($siteconfig['sender_email'])) {
// $field->notes = $this->attentionMessage($siteconfig['sender_email']);
// $field->attr('tabindex', '-1');
// }
$field->columnWidth = 50;
$field->icon = 'at';
$fieldset->add($field);
$field = $modules->get('InputfieldText');
$field->attr('name', 'debug_recipientemail');
$field->attr('value', '');
$field->label = $this->_('Recipient Email Address');
$field->columnWidth = 50;
$field->icon = 'at';
$fieldset->add($field);
$field = $modules->get('InputfieldText');
$field->attr('name', 'debug_subjectline');
$field->attr('value', '');
$field->label = $this->_('Subjectline');
$field->columnWidth = 50;
$field->icon = 'pencil';
$fieldset->add($field);
$field = $modules->get('InputfieldTextarea');
$field->attr('name', 'debug_bodycontent');
$field->attr('value', 'This is a test message. ÄÖÜ äöüß');
$field->label = $this->_('Bodycontent');
$field->columnWidth = 50;
$field->icon = 'envelope-o';
$fieldset->add($field);
$form->add($fieldset);
if(wire('session')->test_settings) {
// EXECUTE DEBUG CONNECTION AND DISPLAY LOG
$field = $modules->get('InputfieldMarkup');
$field->attr('name', '_debug_log');
$field->label = 'Debug Log';
$field->icon = 'heartbeat';
$field->columnWidth = 100;
$field->collapsed = Inputfield::collapsedNo;
$field->attr('value', $this->testSettings());
$form->add($field);
} else if(wire('input')->post->_test_settings) {
// PREPARE SESSION FOR DEBUGGING
$session = wire('session');
$session->set('test_settings', 1);
$post = wire('input')->post;
$session->set('debug_senderemail', $post->debug_senderemail);
$session->set('debug_recipientemail', $post->debug_recipientemail);
$session->set('debug_subjectline', $post->debug_subjectline);
$session->set('debug_bodycontent', $post->debug_bodycontent);
}
return $form;
}
public function testSettings() {
try {
$session = wire('session');
$from = $session->get('debug_senderemail');
$to = array($session->get('debug_recipientemail'));
$subject = $session->get('debug_subjectline');
$body = $session->get('debug_bodycontent');
$session->remove('test_settings');
$session->remove('debug_senderemail');
$session->remove('debug_recipientemail');
$session->remove('debug_subjectline');
$session->remove('debug_bodycontent');
if($from && $to) {
// do a verbose debugging
if(!$subject) $subject = 'Debug Testmail';
if(!$body) $body = 'Debug Testmail, äöüß';
$mail = wireMail();
if($mail->className != 'WireMailSmtp') {
$dump = "<p>Couldn't get the right WireMail-Module (WireMailSmtp). found: {$mail->className}</p>";
} else {
$mail->from = $from;
$mail->to($to);
$mail->subject($subject);
$mail->sendSingle(true);
$mail->body($body);
$dump = $mail->debugSend(3);
}
} else {
// only try a testconnection
$module = wire('modules')->get('WireMailSmtp');
$a = $module->getAdaptor();
if($a->testConnection()) {
$dump = $this->_("SUCCESS! SMTP settings appear to work correctly.");
} else {
$dump = $this->_("FAILURE! SMTP settings doesn't appear to work.");
}
}
} catch(Exception $e) {
$dump = $e->getMessage();
}
$outputTemplate = "<pre style=\"overflow:scroll !important; margin:15px auto; padding:10px; background-color:#ffeedd; color:#000; border:1px solid #AAA; font-family:'Hack', 'Source Code Pro', 'Lucida Console', 'Courier', monospace; font-size:12px; line-height:15px;\">".str_replace(array('<br>', '<br/>', '<br />'), '', $dump) ."</pre>";
return $outputTemplate;
}
private function attentionMessage($value) {
return sprintf($this->_("ATTENTION: Value is overwritten by an entry in your site/config.php:\n -[ %s ]- "), $value);
}
private function finalSettingsMessage($siteconfig) {
$outputTemplate = "<pre style=\"overflow:scroll !important; margin:15px auto; padding:10px; background-color:#ffffdd; color:#555; border:1px solid #AAA; font-family:'Hack', 'Source Code Pro', 'Lucida Console', 'Courier', monospace; font-size:12px; line-height:15px;\">[__CONTENT__]</pre>";
if(!count($siteconfig)) {
$content = 'There are no overriding settings defined in your site/config.php';
return str_replace('[__CONTENT__]', $content, $outputTemplate);
}
$validKeys = array(
'localhost',
'smtp_host',
'smtp_port',
'smtp_ssl',
'smtp_ssl_crypto_method',
'smtp_start_tls',
'smtp_tls_crypto_method',
'smtp_user',
'smtp_password',
'allow_without_authentication',
'smtp_certificate',
'realm',
'workstation',
'authentication_mechanism',
'sender_name',
'sender_email',
'sender_reply',
'sender_errors_to',
'sender_signature',
'sender_signature_html',
'extra_headers',
'valid_recipients',
#'smtp_debug',
#'smtp_html_debug',
);
$module = wire('modules')->get('WireMailSmtp');
$dump = $module->getSettings();
$v = array();
foreach($validKeys as $k) {
if(isset($dump[$k])) {
$v[$k] = 'smtp_password' == $k ? '********' : $dump[$k];
}
}
ob_start();
var_dump($v);
$content = ob_get_contents();
ob_end_clean();
$m = 0;
preg_match_all('#^(.*)=>#mU', $content, $stack);
$lines = $stack[1];
$indents = array_map('strlen', $lines);
if($indents) $m = max($indents) + 1;
$content = preg_replace_callback(
'#^(.*)=>\\n\s+(\S)#Um',
function($match) use ($m) {
return $match[1] . str_repeat(' ', ($m - strlen($match[1]) > 1 ? $m - strlen($match[1]) : 1)) . $match[2];
},
$content
);
$content = preg_replace('#^((\s*).*){$#m', "\\1\n\\2{", $content);
$content = str_replace(array('<pre>', '</pre>'), '', $content);
return str_replace('[__CONTENT__]', $content, $outputTemplate);
}
}

View file

@ -0,0 +1,61 @@
<?php
/*
* basic_sasl_client.php
*
* @(#) $Id: basic_sasl_client.php,v 1.1 2004/11/17 08:01:23 mlemos Exp $
*
*/
define("SASL_BASIC_STATE_START", 0);
define("SASL_BASIC_STATE_DONE", 1);
class basic_sasl_client_class
{
var $credentials=array();
var $state=SASL_BASIC_STATE_START;
Function Initialize(&$client)
{
return(1);
}
Function Start(&$client, &$message, &$interactions)
{
if($this->state!=SASL_BASIC_STATE_START)
{
$client->error="Basic authentication state is not at the start";
return(SASL_FAIL);
}
$this->credentials=array(
"user"=>"",
"password"=>""
);
$defaults=array(
);
$status=$client->GetCredentials($this->credentials,$defaults,$interactions);
if($status==SASL_CONTINUE)
{
$message=$this->credentials["user"].":".$this->credentials["password"];
$this->state=SASL_BASIC_STATE_DONE;
}
else
Unset($message);
return($status);
}
Function Step(&$client, $response, &$message, &$interactions)
{
switch($this->state)
{
case SASL_BASIC_STATE_DONE:
$client->error="Basic authentication was finished without success";
return(SASL_FAIL);
default:
$client->error="invalid Basic authentication step state";
return(SASL_FAIL);
}
return(SASL_CONTINUE);
}
};
?>

View file

@ -0,0 +1,67 @@
<?php
/*
* cram_md5_sasl_client.php
*
* @(#) $Id: cram_md5_sasl_client.php,v 1.3 2004/11/17 08:00:37 mlemos Exp $
*
*/
define("SASL_CRAM_MD5_STATE_START", 0);
define("SASL_CRAM_MD5_STATE_RESPOND_CHALLENGE", 1);
define("SASL_CRAM_MD5_STATE_DONE", 2);
class cram_md5_sasl_client_class
{
var $credentials=array();
var $state=SASL_CRAM_MD5_STATE_START;
Function Initialize(&$client)
{
return(1);
}
Function HMACMD5($key,$text)
{
$key=(strlen($key)<64 ? str_pad($key,64,"\0") : substr($key,0,64));
return(md5((str_repeat("\x5c", 64)^$key).pack("H32", md5((str_repeat("\x36", 64)^$key).$text))));
}
Function Start(&$client, &$message, &$interactions)
{
if($this->state!=SASL_CRAM_MD5_STATE_START)
{
$client->error="CRAM-MD5 authentication state is not at the start";
return(SASL_FAIL);
}
$this->credentials=array(
"user"=>"",
"password"=>""
);
$defaults=array();
$status=$client->GetCredentials($this->credentials,$defaults,$interactions);
if($status==SASL_CONTINUE)
$this->state=SASL_CRAM_MD5_STATE_RESPOND_CHALLENGE;
Unset($message);
return($status);
}
Function Step(&$client, $response, &$message, &$interactions)
{
switch($this->state)
{
case SASL_CRAM_MD5_STATE_RESPOND_CHALLENGE:
$message=$this->credentials["user"]." ".$this->HMACMD5($this->credentials["password"], $response);
$this->state=SASL_CRAM_MD5_STATE_DONE;
break;
case SASL_CRAM_MD5_STATE_DONE:
$client->error="CRAM-MD5 authentication was finished without success";
return(SASL_FAIL);
default:
$client->error="invalid CRAM-MD5 authentication step state";
return(SASL_FAIL);
}
return(SASL_CONTINUE);
}
};
?>

View file

@ -0,0 +1,135 @@
<?php
/*
* digest_sasl_client.php
*
* @(#) $Id: digest_sasl_client.php,v 1.1 2005/10/27 05:24:15 mlemos Exp $
*
*/
define('SASL_DIGEST_STATE_START', 0);
define('SASL_DIGEST_STATE_RESPOND_CHALLENGE', 1);
define('SASL_DIGEST_STATE_DONE', 2);
class digest_sasl_client_class
{
var $credentials=array();
var $state=SASL_DIGEST_STATE_START;
Function unq($string)
{
return(($string[0]=='"' && $string[strlen($string)-1]=='"') ? substr($string, 1, strlen($string)-2) : $string);
}
Function H($data)
{
return md5($data);
}
Function KD($secret, $data)
{
return $this->H($secret.':'.$data);
}
Function Initialize(&$client)
{
return(1);
}
Function Start(&$client, &$message, &$interactions)
{
if($this->state!=SASL_DIGEST_STATE_START)
{
$client->error='Digest authentication state is not at the start';
return(SASL_FAIL);
}
$this->credentials=array(
'user'=>'',
'password'=>'',
'uri'=>'',
'method'=>'',
'session'=>''
);
$defaults=array();
$status=$client->GetCredentials($this->credentials,$defaults,$interactions);
if($status==SASL_CONTINUE)
$this->state=SASL_DIGEST_STATE_RESPOND_CHALLENGE;
Unset($message);
return($status);
}
Function Step(&$client, $response, &$message, &$interactions)
{
switch($this->state)
{
case SASL_DIGEST_STATE_RESPOND_CHALLENGE:
$values=explode(',',$response);
$parameters=array();
for($v=0; $v<count($values); $v++)
$parameters[strtok(trim($values[$v]), '=')]=strtok('');
$message='username="'.$this->credentials['user'].'"';
if(!IsSet($parameters[$p='realm'])
&& !IsSet($parameters[$p='nonce']))
{
$client->error='Digest authentication parameter '.$p.' is missing from the server response';
return(SASL_FAIL);
}
$message.=', realm='.$parameters['realm'];
$message.=', nonce='.$parameters['nonce'];
$message.=', uri="'.$this->credentials['uri'].'"';
if(IsSet($parameters['algorithm']))
{
$algorithm=$this->unq($parameters['algorithm']);
$message.=', algorithm='.$parameters['algorithm'];
}
else
$algorithm='';
$realm=$this->unq($parameters['realm']);
$nonce=$this->unq($parameters['nonce']);
if(IsSet($parameters['qop']))
{
switch($qop=$this->unq($parameters['qop']))
{
case "auth":
$cnonce=$this->credentials['session'];
break;
default:
$client->error='Digest authentication quality of protection '.$qop.' is not yet supported';
return(SASL_FAIL);
}
}
$nc_value='00000001';
if(IsSet($parameters['qop'])
&& !strcmp($algorithm, 'MD5-sess'))
$A1=$this->H($this->credentials['user'].':'. $realm.':'. $this->credentials['password']).':'.$nonce.':'.$cnonce;
else
$A1=$this->credentials['user'].':'. $realm.':'. $this->credentials['password'];
$A2=$this->credentials['method'].':'.$this->credentials['uri'];
if(IsSet($parameters['qop']))
$response=$this->KD($this->H($A1), $nonce.':'. $nc_value.':'. $cnonce.':'. $qop.':'. $this->H($A2));
else
$response=$this->KD($this->H($A1), $nonce.':'. $this->H($A2));
$message.=', response="'.$response.'"';
if(IsSet($parameters['opaque']))
$message.=', opaque='.$parameters['opaque'];
if(IsSet($parameters['qop']))
$message.=', qop="'.$qop.'"';
$message.=', nc='.$nc_value;
if(IsSet($parameters['qop']))
$message.=', cnonce="'.$cnonce.'"';
$client->encode_response=0;
$this->state=SASL_DIGEST_STATE_DONE;
break;
case SASL_DIGEST_STATE_DONE:
$client->error='Digest authentication was finished without success';
return(SASL_FAIL);
default:
$client->error='invalid Digest authentication step state';
return(SASL_FAIL);
}
return(SASL_CONTINUE);
}
};
?>

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,193 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Class: Simple Authentication and Security Layer client</title>
</head>
<body>
<center><h1>Class: Simple Authentication and Security Layer client</h1></center>
<hr />
<ul>
<p><b>Version:</b> <tt>@(#) $Id: sasl_class.html,v 1.1 2014/03/03 12:28:31 horst Exp $</tt></p>
<h2><a name="table_of_contents">Contents</a></h2>
<ul>
<li><a href="#2.1.1">Summary</a></li>
<ul>
<li><a href="#3.2.0">Name</a></li>
<li><a href="#3.2.0.0">Author</a></li>
<li><a href="#3.2.0.1">Copyright</a></li>
<li><a href="#3.2.0.2">Version</a></li>
<li><a href="#3.2.0.3">Purpose</a></li>
<li><a href="#3.2.0.4">Usage</a></li>
</ul>
<li><a href="#4.1.1">Variables</a></li>
<ul>
<li><a href="#5.2.4">error</a></li>
<li><a href="#5.2.5">mechanism</a></li>
<li><a href="#5.2.6">encode_response</a></li>
</ul>
<li><a href="#6.1.1">Functions</a></li>
<ul>
<li><a href="#7.2.5">SetCredential</a></li>
<li><a href="#9.2.6">GetCredentials</a></li>
<li><a href="#11.2.7">Start</a></li>
<li><a href="#13.2.8">Step</a></li>
</ul>
</ul>
<p><a href="#table_of_contents">Top of the table of contents</a></p>
</ul>
<hr />
<ul>
<h2><li><a name="2.1.1">Summary</a></li></h2>
<ul>
<h3><a name="3.2.0">Name</a></h3>
<p>Simple Authentication and Security Layer client</p>
<h3><a name="3.2.0.0">Author</a></h3>
<p>Manuel Lemos (<a href="mailto:mlemos-at-acm.org">mlemos-at-acm.org</a>)</p>
<h3><a name="3.2.0.1">Copyright</a></h3>
<p>Copyright &copy; (C) Manuel Lemos 2004</p>
<h3><a name="3.2.0.2">Version</a></h3>
<p>@(#) $Id: sasl_class.html,v 1.1 2014/03/03 12:28:31 horst Exp $</p>
<h3><a name="3.2.0.3">Purpose</a></h3>
<p>Provide a common interface to plug-in driver classes that implement different mechanisms for authentication used by clients of standard protocols like SMTP, POP3, IMAP, HTTP, etc.. Currently the supported authentication mechanisms are: <tt>PLAIN</tt>, <tt>LOGIN</tt>, <tt>CRAM-MD5</tt>, <tt>Digest</tt> and <tt>NTML</tt> (Windows or Samba).</p>
<h3><a name="3.2.0.4">Usage</a></h3>
<p>.</p>
<p><a href="#table_of_contents">Table of contents</a></p>
</ul>
</ul>
<hr />
<ul>
<h2><li><a name="variables"></a><a name="4.1.1">Variables</a></li></h2>
<ul>
<li><tt><a href="#variable_error">error</a></tt></li><br />
<li><tt><a href="#variable_mechanism">mechanism</a></tt></li><br />
<li><tt><a href="#variable_encode_response">encode_response</a></tt></li><br />
<p><a href="#table_of_contents">Table of contents</a></p>
<h3><a name="variable_error"></a><li><a name="5.2.4">error</a></li></h3>
<h3>Type</h3>
<p><tt><i>string</i></tt></p>
<h3>Default value</h3>
<p><tt>''</tt></p>
<h3>Purpose</h3>
<p>Store the message that is returned when an error occurs.</p>
<h3>Usage</h3>
<p>Check this variable to understand what happened when a call to any of the class functions has failed.</p>
<p> This class uses cumulative error handling. This means that if one class functions that may fail is called and this variable was already set to an error message due to a failure in a previous call to the same or other function, the function will also fail and does not do anything.</p>
<p> This allows programs using this class to safely call several functions that may fail and only check the failure condition after the last function call.</p>
<p> Just set this variable to an empty string to clear the error condition.</p>
<p><a href="#variables">Variables</a></p>
<h3><a name="variable_mechanism"></a><li><a name="5.2.5">mechanism</a></li></h3>
<h3>Type</h3>
<p><tt><i>string</i></tt></p>
<h3>Default value</h3>
<p><tt>''</tt></p>
<h3>Purpose</h3>
<p>Store the name of the mechanism that was selected during the call to the <tt><a href="#function_Start">Start</a></tt> function.</p>
<h3>Usage</h3>
<p>You can access this variable but do not change it.</p>
<p><a href="#variables">Variables</a></p>
<h3><a name="variable_encode_response"></a><li><a name="5.2.6">encode_response</a></li></h3>
<h3>Type</h3>
<p><tt><i>bool</i></tt></p>
<h3>Default value</h3>
<p><tt>1</tt></p>
<h3>Purpose</h3>
<p>Let the drivers inform the applications whether responses need to be encoded.</p>
<h3>Usage</h3>
<p>Applications should check this variable before sending authentication responses to the server to determine if the responses need to be encoded, eventually with base64 algorithm.</p>
<p><a href="#variables">Variables</a></p>
<p><a href="#table_of_contents">Table of contents</a></p>
</ul>
</ul>
<hr />
<ul>
<h2><li><a name="functions"></a><a name="6.1.1">Functions</a></li></h2>
<ul>
<li><tt><a href="#function_SetCredential">SetCredential</a></tt></li><br />
<li><tt><a href="#function_GetCredentials">GetCredentials</a></tt></li><br />
<li><tt><a href="#function_Start">Start</a></tt></li><br />
<li><tt><a href="#function_Step">Step</a></tt></li><br />
<p><a href="#table_of_contents">Table of contents</a></p>
<h3><a name="function_SetCredential"></a><li><a name="7.2.5">SetCredential</a></li></h3>
<h3>Synopsis</h3>
<p><tt><i></i> SetCredential(</tt><ul>
<tt><i>string</i> </tt><tt><a href="#argument_SetCredential_key">key</a></tt><tt>,</tt><br />
<tt><i>string</i> </tt><tt><a href="#argument_SetCredential_value">value</a></tt></ul>
<tt>)</tt></p>
<h3>Purpose</h3>
<p>Store the value of a credential that may be used by any of the supported mechanisms to process the authentication messages and responses.</p>
<h3>Usage</h3>
<p>Call this function before starting the authentication dialog to pass all the credential values that be needed to use the type of authentication that the applications may need.</p>
<h3>Arguments</h3>
<ul>
<p><tt><b><a name="argument_SetCredential_key">key</a></b></tt> - Specify the name of the credential key.</p>
<p><tt><b><a name="argument_SetCredential_value">value</a></b></tt> - Specify the value for the credential.</p>
</ul>
<p><a href="#functions">Functions</a></p>
<h3><a name="function_GetCredentials"></a><li><a name="9.2.6">GetCredentials</a></li></h3>
<h3>Synopsis</h3>
<p><tt><i>int</i> GetCredentials(</tt><ul>
<tt>(input and output) <i>array</i> </tt><tt><a href="#argument_GetCredentials_credentials">credentials</a></tt><tt>,</tt><br />
<tt>(input and output) <i>array</i> </tt><tt><a href="#argument_GetCredentials_defaults">defaults</a></tt><tt>,</tt><br />
<tt>(input and output) <i>array</i> </tt><tt><a href="#argument_GetCredentials_interactions">interactions</a></tt></ul>
<tt>)</tt></p>
<h3>Purpose</h3>
<p>Retrieve the values of one or more credentials to be used by the authentication mechanism classes.</p>
<h3>Usage</h3>
<p>This is meant to be used by authentication mechanism driver classes to retrieve the credentials that may be neede.</p>
<h3>Arguments</h3>
<ul>
<p><tt><b><a name="argument_GetCredentials_credentials">credentials</a></b></tt> - Reference to an associative array variable with all the credentials that are being requested. The function initializes this associative array values.</p>
<p><tt><b><a name="argument_GetCredentials_defaults">defaults</a></b></tt> - Associative arrays with default values for credentials that may have not been defined.</p>
<p><tt><b><a name="argument_GetCredentials_interactions">interactions</a></b></tt> - Not yet in use. It is meant to provide context information to retrieve credentials that may be obtained interacting with the user.</p>
</ul>
<h3>Return value</h3>
<p>The function may return <tt>SASL_CONTINUE</tt> if it succeeded, or <tt>SASL_NOMECH</tt> if it was not possible to retrieve one of the requested credentials.</p>
<p><a href="#functions">Functions</a></p>
<h3><a name="function_Start"></a><li><a name="11.2.7">Start</a></li></h3>
<h3>Synopsis</h3>
<p><tt><i>int</i> Start(</tt><ul>
<tt>(input and output) <i>array</i> </tt><tt><a href="#argument_Start_mechanisms">mechanisms</a></tt><tt>,</tt><br />
<tt>(output) <i>string &amp;</i> </tt><tt><a href="#argument_Start_message">message</a></tt><tt>,</tt><br />
<tt>(input and output) <i>array</i> </tt><tt><a href="#argument_Start_interactions">interactions</a></tt></ul>
<tt>)</tt></p>
<h3>Purpose</h3>
<p>Process the initial authentication step initializing the driver class that implements the first of the list of requested mechanisms that is supported by this SASL client library implementation.</p>
<h3>Usage</h3>
<p>Call this function specifying a list of mechanisms that the server supports. If the <tt><a href="#argument_Start_message">message</a></tt> argument returns a string, it should be sent to the server as initial message. Check the <tt><a href="#variable_encode_response">encode_response</a></tt> variable to determine whether the initial message needs to be encoded, eventually with base64 algorithm, before it is sent to the server.</p>
<h3>Arguments</h3>
<ul>
<p><tt><b><a name="argument_Start_mechanisms">mechanisms</a></b></tt> - Define the list of names of authentication mechanisms supported by the that should be tried.</p>
<p><tt><b><a name="argument_Start_message">message</a></b></tt> - Return the initial message that should be sent to the server to start the authentication dialog. If this value is undefined, no message should be sent to the server.</p>
<p><tt><b><a name="argument_Start_interactions">interactions</a></b></tt> - Not yet in use. It is meant to provide context information to interact with the end user.</p>
</ul>
<h3>Return value</h3>
<p>The function may return <tt>SASL_CONTINUE</tt> if it could start one of the requested authentication mechanisms. It may return <tt>SASL_NOMECH</tt> if it was not possible to start any of the requested mechanisms. It returns <tt>SASL_FAIL</tt> or other value in case of error.</p>
<p><a href="#functions">Functions</a></p>
<h3><a name="function_Step"></a><li><a name="13.2.8">Step</a></li></h3>
<h3>Synopsis</h3>
<p><tt><i>int</i> Step(</tt><ul>
<tt><i>string</i> </tt><tt><a href="#argument_Step_response">response</a></tt><tt>,</tt><br />
<tt>(output) <i>string &amp;</i> </tt><tt><a href="#argument_Step_message">message</a></tt><tt>,</tt><br />
<tt>(input and output) <i>array</i> </tt><tt><a href="#argument_Step_interactions">interactions</a></tt></ul>
<tt>)</tt></p>
<h3>Purpose</h3>
<p>Process the authentication steps after the initial step, until the authetication iteration dialog is complete.</p>
<h3>Usage</h3>
<p>Call this function iteratively after a successful initial step calling the <tt><a href="#function_Start">Start</a></tt> function.</p>
<h3>Arguments</h3>
<ul>
<p><tt><b><a name="argument_Step_response">response</a></b></tt> - Pass the response returned by the server to the previous step.</p>
<p><tt><b><a name="argument_Step_message">message</a></b></tt> - Return the message that should be sent to the server to continue the authentication dialog. If this value is undefined, no message should be sent to the server.</p>
<p><tt><b><a name="argument_Step_interactions">interactions</a></b></tt> - Not yet in use. It is meant to provide context information to interact with the end user.</p>
</ul>
<h3>Return value</h3>
<p>The function returns <tt>SASL_CONTINUE</tt> if step was processed successfully, or returns <tt>SASL_FAIL</tt> in case of error.</p>
<p><a href="#functions">Functions</a></p>
<p><a href="#table_of_contents">Table of contents</a></p>
</ul>
</ul>
<hr />
<address>Manuel Lemos (<a href="mailto:mlemos-at-acm.org">mlemos-at-acm.org</a>)</address>
</body>
</html>

View file

@ -0,0 +1,584 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Class: Sending e-mail messages via SMTP protocol</title>
</head>
<body>
<center><h1>Class: Sending e-mail messages via SMTP protocol</h1></center>
<hr />
<ul>
<p><b>Version:</b> <tt>@(#) $Id: smtp_class.html,v 1.1 2014/03/03 12:28:31 horst Exp $</tt></p>
<h2><a name="table_of_contents">Contents</a></h2>
<ul>
<li><a href="#2.1.1">Summary</a></li>
<ul>
<li><a href="#3.2.0">Name</a></li>
<li><a href="#3.2.0.0">Author</a></li>
<li><a href="#3.2.0.1">Copyright</a></li>
<li><a href="#3.2.0.2">Version</a></li>
<li><a href="#3.2.0.3">Purpose</a></li>
<li><a href="#3.2.0.4">Translation</a></li>
<li><a href="#3.2.0.5">Support</a></li>
<li><a href="#3.2.0.6">Usage</a></li>
</ul>
<li><a href="#4.1.1">Variables</a></li>
<ul>
<li><a href="#5.2.29">user</a></li>
<li><a href="#5.2.30">realm</a></li>
<li><a href="#5.2.31">password</a></li>
<li><a href="#5.2.32">workstation</a></li>
<li><a href="#5.2.33">authentication_mechanism</a></li>
<li><a href="#5.2.34">host_name</a></li>
<li><a href="#5.2.35">host_port</a></li>
<li><a href="#5.2.36">socks_host_name</a></li>
<li><a href="#5.2.37">socks_host_port</a></li>
<li><a href="#5.2.38">socks_version</a></li>
<li><a href="#5.2.39">http_proxy_host_name</a></li>
<li><a href="#5.2.40">http_proxy_host_port</a></li>
<li><a href="#5.2.41">user_agent</a></li>
<li><a href="#5.2.42">ssl</a></li>
<li><a href="#5.2.43">start_tls</a></li>
<li><a href="#5.2.44">localhost</a></li>
<li><a href="#5.2.45">timeout</a></li>
<li><a href="#5.2.46">data_timeout</a></li>
<li><a href="#5.2.47">direct_delivery</a></li>
<li><a href="#5.2.48">error</a></li>
<li><a href="#5.2.49">debug</a></li>
<li><a href="#5.2.50">html_debug</a></li>
<li><a href="#5.2.51">esmtp</a></li>
<li><a href="#5.2.52">esmtp_extensions</a></li>
<li><a href="#5.2.53">exclude_address</a></li>
<li><a href="#5.2.54">getmxrr</a></li>
<li><a href="#5.2.55">pop3_auth_host</a></li>
<li><a href="#5.2.56">pop3_auth_port</a></li>
</ul>
<li><a href="#6.1.1">Functions</a></li>
<ul>
<li><a href="#7.2.11">Connect</a></li>
<li><a href="#9.2.12">MailFrom</a></li>
<li><a href="#11.2.13">SetRecipient</a></li>
<li><a href="#13.2.14">StartData</a></li>
<li><a href="#13.2.15">PrepareData</a></li>
<li><a href="#15.2.16">SendData</a></li>
<li><a href="#17.2.17">EndSendingData</a></li>
<li><a href="#17.2.18">ResetConnection</a></li>
<li><a href="#17.2.19">Disconnect</a></li>
<li><a href="#19.2.20">SendMessage</a></li>
</ul>
</ul>
<p><a href="#table_of_contents">Top of the table of contents</a></p>
</ul>
<hr />
<ul>
<h2><li><a name="2.1.1">Summary</a></li></h2>
<ul>
<h3><a name="3.2.0">Name</a></h3>
<p>Sending e-mail messages via SMTP protocol</p>
<h3><a name="3.2.0.0">Author</a></h3>
<p>Manuel Lemos (<a href="mailto:mlemos-at-acm.org">mlemos-at-acm.org</a>)</p>
<h3><a name="3.2.0.1">Copyright</a></h3>
<p>Copyright (C) Manuel Lemos 1999-2011</p>
<h3><a name="3.2.0.2">Version</a></h3>
<p>@(#) $Id: smtp_class.html,v 1.1 2014/03/03 12:28:31 horst Exp $</p>
<h3><a name="3.2.0.3">Purpose</a></h3>
<p>Sending e-mail messages via SMTP protocol</p>
<h3><a name="3.2.0.4">Translation</a></h3>
<p>If you are interested in translating the documentation of this class to your own idiom, please <a href="mailto:mlemos-at-acm.org">contact the author</a>.</p>
<h3><a name="3.2.0.5">Support</a></h3>
<p>Technical support for using this class may be obtained in the <tt>smtpclass</tt> support forum. Just go to the support forum pages page to browse the forum archives and post support request messages:</p>
<p> <a href="http://www.phpclasses.org/discuss/package/14/">http://www.phpclasses.org/discuss/package/14/</a></p>
<h3><a name="3.2.0.6">Usage</a></h3>
<p>To use this class just create a new object, set any variables to configure its options and call the <tt><a href="#function_SendMessage">SendMessage</a></tt> function to send a message.</p>
<p>It is not recommended that you use this class alone unless you have deep understanding of Internet mail standards on how to compose compliant e-mail messages. Instead, use the <a href="http://www.phpclasses.org/mimemessage">MIME message composing and sending class</a> and its sub-class SMTP message together with this SMTP class to properly compose e-mail messages, so your messages are not discarded for not being correctly composed.</p>
<p><a href="#table_of_contents">Table of contents</a></p>
</ul>
</ul>
<hr />
<ul>
<h2><li><a name="variables"></a><a name="4.1.1">Variables</a></li></h2>
<ul>
<li><tt><a href="#variable_user">user</a></tt></li><br />
<li><tt><a href="#variable_realm">realm</a></tt></li><br />
<li><tt><a href="#variable_password">password</a></tt></li><br />
<li><tt><a href="#variable_workstation">workstation</a></tt></li><br />
<li><tt><a href="#variable_authentication_mechanism">authentication_mechanism</a></tt></li><br />
<li><tt><a href="#variable_host_name">host_name</a></tt></li><br />
<li><tt><a href="#variable_host_port">host_port</a></tt></li><br />
<li><tt><a href="#variable_socks_host_name">socks_host_name</a></tt></li><br />
<li><tt><a href="#variable_socks_host_port">socks_host_port</a></tt></li><br />
<li><tt><a href="#variable_socks_version">socks_version</a></tt></li><br />
<li><tt><a href="#variable_http_proxy_host_name">http_proxy_host_name</a></tt></li><br />
<li><tt><a href="#variable_http_proxy_host_port">http_proxy_host_port</a></tt></li><br />
<li><tt><a href="#variable_user_agent">user_agent</a></tt></li><br />
<li><tt><a href="#variable_ssl">ssl</a></tt></li><br />
<li><tt><a href="#variable_start_tls">start_tls</a></tt></li><br />
<li><tt><a href="#variable_localhost">localhost</a></tt></li><br />
<li><tt><a href="#variable_timeout">timeout</a></tt></li><br />
<li><tt><a href="#variable_data_timeout">data_timeout</a></tt></li><br />
<li><tt><a href="#variable_direct_delivery">direct_delivery</a></tt></li><br />
<li><tt><a href="#variable_error">error</a></tt></li><br />
<li><tt><a href="#variable_debug">debug</a></tt></li><br />
<li><tt><a href="#variable_html_debug">html_debug</a></tt></li><br />
<li><tt><a href="#variable_esmtp">esmtp</a></tt></li><br />
<li><tt><a href="#variable_esmtp_extensions">esmtp_extensions</a></tt></li><br />
<li><tt><a href="#variable_exclude_address">exclude_address</a></tt></li><br />
<li><tt><a href="#variable_getmxrr">getmxrr</a></tt></li><br />
<li><tt><a href="#variable_pop3_auth_host">pop3_auth_host</a></tt></li><br />
<li><tt><a href="#variable_pop3_auth_port">pop3_auth_port</a></tt></li><br />
<p><a href="#table_of_contents">Table of contents</a></p>
<h3><a name="variable_user"></a><li><a name="5.2.29">user</a></li></h3>
<h3>Type</h3>
<p><tt><i>string</i></tt></p>
<h3>Default value</h3>
<p><tt>''</tt></p>
<h3>Purpose</h3>
<p>Define the authorized user when sending messages to a SMTP server.</p>
<h3>Usage</h3>
<p>Set this variable to the user name when the SMTP server requires authentication.</p>
<p><a href="#variables">Variables</a></p>
<h3><a name="variable_realm"></a><li><a name="5.2.30">realm</a></li></h3>
<h3>Type</h3>
<p><tt><i>string</i></tt></p>
<h3>Default value</h3>
<p><tt>''</tt></p>
<h3>Purpose</h3>
<p>Define the authentication realm when sending messages to a SMTP server.</p>
<h3>Usage</h3>
<p>Set this variable when the SMTP server requires authentication and if more than one authentication realm is supported.</p>
<p><a href="#variables">Variables</a></p>
<h3><a name="variable_password"></a><li><a name="5.2.31">password</a></li></h3>
<h3>Type</h3>
<p><tt><i>string</i></tt></p>
<h3>Default value</h3>
<p><tt>''</tt></p>
<h3>Purpose</h3>
<p>Define the authorized user password when sending messages to a SMTP server.</p>
<h3>Usage</h3>
<p>Set this variable to the user password when the SMTP server requires authentication.</p>
<p><a href="#variables">Variables</a></p>
<h3><a name="variable_workstation"></a><li><a name="5.2.32">workstation</a></li></h3>
<h3>Type</h3>
<p><tt><i>string</i></tt></p>
<h3>Default value</h3>
<p><tt>''</tt></p>
<h3>Purpose</h3>
<p>Define the client workstation name when sending messages to a SMTP server.</p>
<h3>Usage</h3>
<p>Set this variable to the client workstation when the SMTP server requires authentication identifiying the origin workstation name.</p>
<p><a href="#variables">Variables</a></p>
<h3><a name="variable_authentication_mechanism"></a><li><a name="5.2.33">authentication_mechanism</a></li></h3>
<h3>Type</h3>
<p><tt><i>string</i></tt></p>
<h3>Default value</h3>
<p><tt>''</tt></p>
<h3>Purpose</h3>
<p>Force the use of a specific authentication mechanism.</p>
<h3>Usage</h3>
<p>Set it to an empty string to let the class determine the authentication mechanism to use automatically based on the supported mechanisms by the server and by the SASL client library classes.</p>
<p> Set this variable to a specific mechanism name if you want to override the automatic authentication mechanism selection.</p>
<p><a href="#variables">Variables</a></p>
<h3><a name="variable_host_name"></a><li><a name="5.2.34">host_name</a></li></h3>
<h3>Type</h3>
<p><tt><i>string</i></tt></p>
<h3>Default value</h3>
<p><tt>''</tt></p>
<h3>Purpose</h3>
<p>Define the SMTP server host name.</p>
<h3>Usage</h3>
<p>Set to the host name of the SMTP server to which you want to relay the messages.</p>
<p><a href="#variables">Variables</a></p>
<h3><a name="variable_host_port"></a><li><a name="5.2.35">host_port</a></li></h3>
<h3>Type</h3>
<p><tt><i>int</i></tt></p>
<h3>Default value</h3>
<p><tt>25</tt></p>
<h3>Purpose</h3>
<p>Define the SMTP server host port.</p>
<h3>Usage</h3>
<p>Set to the TCP port of the SMTP server host to connect.</p>
<p><a href="#variables">Variables</a></p>
<h3><a name="variable_socks_host_name"></a><li><a name="5.2.36">socks_host_name</a></li></h3>
<h3>Type</h3>
<p><tt><i>string</i></tt></p>
<h3>Default value</h3>
<p><tt>''</tt></p>
<h3>Purpose</h3>
<p>Define the SOCKS server host name.</p>
<h3>Usage</h3>
<p>Set to the SOCKS server host name through which the SMTP connection should be routed. Leave it empty if you do not want the connections to be established through a SOCKS server.</p>
<p><a href="#variables">Variables</a></p>
<h3><a name="variable_socks_host_port"></a><li><a name="5.2.37">socks_host_port</a></li></h3>
<h3>Type</h3>
<p><tt><i>int</i></tt></p>
<h3>Default value</h3>
<p><tt>1080</tt></p>
<h3>Purpose</h3>
<p>Define the SOCKS server host port.</p>
<h3>Usage</h3>
<p>Set to the port of the SOCKS server host through which the the SMTP connection should be routed.</p>
<p><a href="#variables">Variables</a></p>
<h3><a name="variable_socks_version"></a><li><a name="5.2.38">socks_version</a></li></h3>
<h3>Type</h3>
<p><tt><i>string</i></tt></p>
<h3>Default value</h3>
<p><tt>'5'</tt></p>
<h3>Purpose</h3>
<p>Set the SOCKS protocol version.</p>
<h3>Usage</h3>
<p>Change this value if SOCKS server you want to use is listening to a different port.</p>
<p><a href="#variables">Variables</a></p>
<h3><a name="variable_http_proxy_host_name"></a><li><a name="5.2.39">http_proxy_host_name</a></li></h3>
<h3>Type</h3>
<p><tt><i>string</i></tt></p>
<h3>Default value</h3>
<p><tt>''</tt></p>
<h3>Purpose</h3>
<p>Define the HTTP proxy server host name.</p>
<h3>Usage</h3>
<p>Set to the HTTP proxy server host name through which the SMTP connection should be routed. Leave it empty if you do not want the connections to be established through an HTTP proxy.</p>
<p><a href="#variables">Variables</a></p>
<h3><a name="variable_http_proxy_host_port"></a><li><a name="5.2.40">http_proxy_host_port</a></li></h3>
<h3>Type</h3>
<p><tt><i>int</i></tt></p>
<h3>Default value</h3>
<p><tt>80</tt></p>
<h3>Purpose</h3>
<p>Define the HTTP proxy server host port.</p>
<h3>Usage</h3>
<p>Set to the port of the HTTP proxy server host through which the SMTP connection should be routed.</p>
<p><a href="#variables">Variables</a></p>
<h3><a name="variable_user_agent"></a><li><a name="5.2.41">user_agent</a></li></h3>
<h3>Type</h3>
<p><tt><i>string</i></tt></p>
<h3>Default value</h3>
<p><tt>'SMTP Class (http://www.phpclasses.org/smtpclass $Revision: 1.1 $)'</tt></p>
<h3>Purpose</h3>
<p>Set the user agent used when connecting via an HTTP proxy.</p>
<h3>Usage</h3>
<p>Change this value only if for some reason you want emulate a certain e-mail client.</p>
<p><a href="#variables">Variables</a></p>
<h3><a name="variable_ssl"></a><li><a name="5.2.42">ssl</a></li></h3>
<h3>Type</h3>
<p><tt><i>bool</i></tt></p>
<h3>Default value</h3>
<p><tt>0</tt></p>
<h3>Purpose</h3>
<p>Define whether the connection to the SMTP server should be established securely using SSL protocol.</p>
<h3>Usage</h3>
<p>Set to 1 if the SMTP server requires secure connections using SSL protocol.</p>
<p><a href="#variables">Variables</a></p>
<h3><a name="variable_start_tls"></a><li><a name="5.2.43">start_tls</a></li></h3>
<h3>Type</h3>
<p><tt><i>bool</i></tt></p>
<h3>Default value</h3>
<p><tt>0</tt></p>
<h3>Purpose</h3>
<p>Define whether the connection to the SMTP server should use encryption after the connection is established using TLS protocol.</p>
<h3>Usage</h3>
<p>Set to 1 if the SMTP server requires that authentication be done securely starting the TLS protocol after the connection is established.</p>
<p><a href="#variables">Variables</a></p>
<h3><a name="variable_localhost"></a><li><a name="5.2.44">localhost</a></li></h3>
<h3>Type</h3>
<p><tt><i>string</i></tt></p>
<h3>Default value</h3>
<p><tt>''</tt></p>
<h3>Purpose</h3>
<p>Name of the local host computer</p>
<h3>Usage</h3>
<p>Set to the name of the computer connecting to the SMTP server from the local network.</p>
<p><a href="#variables">Variables</a></p>
<h3><a name="variable_timeout"></a><li><a name="5.2.45">timeout</a></li></h3>
<h3>Type</h3>
<p><tt><i>int</i></tt></p>
<h3>Default value</h3>
<p><tt>0</tt></p>
<h3>Purpose</h3>
<p>Specify the connection timeout period in seconds.</p>
<h3>Usage</h3>
<p>Leave it set to 0 if you want the connection attempts to wait forever. Change this value if for some reason the timeout period seems insufficient or otherwise it seems too long.</p>
<p><a href="#variables">Variables</a></p>
<h3><a name="variable_data_timeout"></a><li><a name="5.2.46">data_timeout</a></li></h3>
<h3>Type</h3>
<p><tt><i>int</i></tt></p>
<h3>Default value</h3>
<p><tt>0</tt></p>
<h3>Purpose</h3>
<p>Specify the timeout period in seconds to wait for data from the server.</p>
<h3>Usage</h3>
<p>Leave it set to 0 if you want to use the same value defined in the <tt><a href="#variable_timeout">timeout</a></tt> variable. Change this value if for some reason the default data timeout period seems insufficient or otherwise it seems too long.</p>
<p><a href="#variables">Variables</a></p>
<h3><a name="variable_direct_delivery"></a><li><a name="5.2.47">direct_delivery</a></li></h3>
<h3>Type</h3>
<p><tt><i>bool</i></tt></p>
<h3>Default value</h3>
<p><tt>0</tt></p>
<h3>Purpose</h3>
<p>Boolean flag that indicates whether the message should be sent in direct delivery mode, i.e. the message is sent to the SMTP server associated to the domain of the recipient instead of relaying to the server specified by the <tt><a href="#variable_host_name">host_name</a></tt> variable.</p>
<h3>Usage</h3>
<p>Set this to <tt>1</tt> if you want to send urgent messages directly to the recipient domain SMTP server.</p>
<p><a href="#variables">Variables</a></p>
<h3><a name="variable_error"></a><li><a name="5.2.48">error</a></li></h3>
<h3>Type</h3>
<p><tt><i>string</i></tt></p>
<h3>Default value</h3>
<p><tt>''</tt></p>
<h3>Purpose</h3>
<p>Message that describes the error when a call to a class function fails.</p>
<h3>Usage</h3>
<p>Check this variable when an error occurs to understand what happened.</p>
<p><a href="#variables">Variables</a></p>
<h3><a name="variable_debug"></a><li><a name="5.2.49">debug</a></li></h3>
<h3>Type</h3>
<p><tt><i>bool</i></tt></p>
<h3>Default value</h3>
<p><tt>0</tt></p>
<h3>Purpose</h3>
<p>Specify whether it is necessary to output SMTP connection debug information.</p>
<h3>Usage</h3>
<p>Set this variable to <tt>1</tt> if you need to see the progress of the SMTP connection and protocol dialog when you need to understand the reason for delivery problems.</p>
<p><a href="#variables">Variables</a></p>
<h3><a name="variable_html_debug"></a><li><a name="5.2.50">html_debug</a></li></h3>
<h3>Type</h3>
<p><tt><i>bool</i></tt></p>
<h3>Default value</h3>
<p><tt>0</tt></p>
<h3>Purpose</h3>
<p>Specify whether the debug information should be outputted in HTML format.</p>
<h3>Usage</h3>
<p>Set this variable to <tt>1</tt> if you need to see the debug output in a Web page.</p>
<p><a href="#variables">Variables</a></p>
<h3><a name="variable_esmtp"></a><li><a name="5.2.51">esmtp</a></li></h3>
<h3>Type</h3>
<p><tt><i>bool</i></tt></p>
<h3>Default value</h3>
<p><tt>1</tt></p>
<h3>Purpose</h3>
<p>Specify whether the class should attempt to use ESMTP extensions supported by the server.</p>
<h3>Usage</h3>
<p>Set this variable to <tt>0</tt> if for some reason you want to avoid benefitting from ESMTP extensions.</p>
<p><a href="#variables">Variables</a></p>
<h3><a name="variable_esmtp_extensions"></a><li><a name="5.2.52">esmtp_extensions</a></li></h3>
<h3>Type</h3>
<p><tt><i>array</i></tt></p>
<h3>Default value</h3>
<p><tt>array()</tt></p>
<h3>Purpose</h3>
<p>Associative array with the list of ESMTP extensions supported by the SMTP server.</p>
<h3>Usage</h3>
<p>Check this variable after connecting to the SMTP server to determine which ESMTP extensions are supported.</p>
<p><a href="#variables">Variables</a></p>
<h3><a name="variable_exclude_address"></a><li><a name="5.2.53">exclude_address</a></li></h3>
<h3>Type</h3>
<p><tt><i>string</i></tt></p>
<h3>Default value</h3>
<p><tt>''</tt></p>
<h3>Purpose</h3>
<p>Specify an address that should be considered invalid when resolving host name addresses.</p>
<h3>Usage</h3>
<p>In some networks any domain name that does not exist is resolved as a sub-domain of the default local domain. If the DNS is configured in such way that it always resolves any sub-domain of the default local domain to a given address, it is hard to determine whether a given domain does not exist.</p>
<p> If your network is configured this way, you may set this variable to the address that all sub-domains of the default local domain resolves, so the class can assume that such address is invalid.</p>
<p><a href="#variables">Variables</a></p>
<h3><a name="variable_getmxrr"></a><li><a name="5.2.54">getmxrr</a></li></h3>
<h3>Type</h3>
<p><tt><i>string</i></tt></p>
<h3>Default value</h3>
<p><tt>'getmxrr'</tt></p>
<h3>Purpose</h3>
<p>Specify the name of the function that is called to determine the SMTP server address of a given domain.</p>
<h3>Usage</h3>
<p>Change this to a working replacement of the PHP <tt>getmxrr()</tt> function if this is not working in your system and you want to send messages in direct delivery mode.</p>
<p><a href="#variables">Variables</a></p>
<h3><a name="variable_pop3_auth_host"></a><li><a name="5.2.55">pop3_auth_host</a></li></h3>
<h3>Type</h3>
<p><tt><i>string</i></tt></p>
<h3>Default value</h3>
<p><tt>''</tt></p>
<h3>Purpose</h3>
<p>Specify the server address for POP3 based authentication.</p>
<h3>Usage</h3>
<p>Set this variable to the address of the POP3 server if the SMTP server requires POP3 based authentication.</p>
<p><a href="#variables">Variables</a></p>
<h3><a name="variable_pop3_auth_port"></a><li><a name="5.2.56">pop3_auth_port</a></li></h3>
<h3>Type</h3>
<p><tt><i>int</i></tt></p>
<h3>Default value</h3>
<p><tt>110</tt></p>
<h3>Purpose</h3>
<p>Specify the server port for POP3 based authentication.</p>
<h3>Usage</h3>
<p>Set this variable to the port of the POP3 server if the SMTP server requires POP3 based authentication.</p>
<p><a href="#variables">Variables</a></p>
<p><a href="#table_of_contents">Table of contents</a></p>
</ul>
</ul>
<hr />
<ul>
<h2><li><a name="functions"></a><a name="6.1.1">Functions</a></li></h2>
<ul>
<li><tt><a href="#function_Connect">Connect</a></tt></li><br />
<li><tt><a href="#function_MailFrom">MailFrom</a></tt></li><br />
<li><tt><a href="#function_SetRecipient">SetRecipient</a></tt></li><br />
<li><tt><a href="#function_StartData">StartData</a></tt></li><br />
<li><tt><a href="#function_PrepareData">PrepareData</a></tt></li><br />
<li><tt><a href="#function_SendData">SendData</a></tt></li><br />
<li><tt><a href="#function_EndSendingData">EndSendingData</a></tt></li><br />
<li><tt><a href="#function_ResetConnection">ResetConnection</a></tt></li><br />
<li><tt><a href="#function_Disconnect">Disconnect</a></tt></li><br />
<li><tt><a href="#function_SendMessage">SendMessage</a></tt></li><br />
<p><a href="#table_of_contents">Table of contents</a></p>
<h3><a name="function_Connect"></a><li><a name="7.2.11">Connect</a></li></h3>
<h3>Synopsis</h3>
<p><tt><i>bool</i> Connect(</tt><ul>
<tt><i>string</i> </tt><tt><a href="#argument_Connect_domain">domain</a></tt> [default '']</ul>
<tt>)</tt></p>
<h3>Purpose</h3>
<p>Connect to an SMTP server.</p>
<h3>Usage</h3>
<p>Call this function as first step to send e-mail messages.</p>
<h3>Arguments</h3>
<ul>
<p><tt><b><a name="argument_Connect_domain">domain</a></b></tt> - Specify the domain of the recipient when using the direct delivery mode.</p>
</ul>
<h3>Return value</h3>
<p>The function returns <tt>1</tt> if the connection is successfully established.</p>
<p><a href="#functions">Functions</a></p>
<h3><a name="function_MailFrom"></a><li><a name="9.2.12">MailFrom</a></li></h3>
<h3>Synopsis</h3>
<p><tt><i>bool</i> MailFrom(</tt><ul>
<tt><i>string</i> </tt><tt><a href="#argument_MailFrom_sender">sender</a></tt></ul>
<tt>)</tt></p>
<h3>Purpose</h3>
<p>Set the address of the message sender.</p>
<h3>Usage</h3>
<p>Call this function right after establishing a connection with the <tt><a href="#function_Connect">Connect</a></tt> function.</p>
<h3>Arguments</h3>
<ul>
<p><tt><b><a name="argument_MailFrom_sender">sender</a></b></tt> - E-mail address of the sender.</p>
</ul>
<h3>Return value</h3>
<p>The function returns <tt>1</tt> if the sender address is successfully set.</p>
<p><a href="#functions">Functions</a></p>
<h3><a name="function_SetRecipient"></a><li><a name="11.2.13">SetRecipient</a></li></h3>
<h3>Synopsis</h3>
<p><tt><i>bool</i> SetRecipient(</tt><ul>
<tt><i>string</i> </tt><tt><a href="#argument_SetRecipient_recipient">recipient</a></tt></ul>
<tt>)</tt></p>
<h3>Purpose</h3>
<p>Set the address of a message recipient.</p>
<h3>Usage</h3>
<p>Call this function repeatedly for each recipient right after setting the message sender with the <tt><a href="#function_MailFrom">MailFrom</a></tt> function.</p>
<h3>Arguments</h3>
<ul>
<p><tt><b><a name="argument_SetRecipient_recipient">recipient</a></b></tt> - E-mail address of a recipient.</p>
</ul>
<h3>Return value</h3>
<p>The function returns <tt>1</tt> if the recipient address is successfully set.</p>
<p><a href="#functions">Functions</a></p>
<h3><a name="function_StartData"></a><li><a name="13.2.14">StartData</a></li></h3>
<h3>Synopsis</h3>
<p><tt><i>bool</i> StartData(</tt><tt>)</tt></p>
<h3>Purpose</h3>
<p>Tell the SMTP server that the message data will start being sent.</p>
<h3>Usage</h3>
<p>Call this function right after you are done setting all the message recipients with the <tt><a href="#function_SetRecipient">SetRecipient</a></tt> function.</p>
<h3>Return value</h3>
<p>The function returns <tt>1</tt> if the server is ready to start receiving the message data.</p>
<p><a href="#functions">Functions</a></p>
<h3><a name="function_PrepareData"></a><li><a name="13.2.15">PrepareData</a></li></h3>
<h3>Synopsis</h3>
<p><tt><i>string</i> PrepareData(</tt><ul>
<tt><i>string</i> </tt><tt><a href="#argument_PrepareData_data">data</a></tt></ul>
<tt>)</tt></p>
<h3>Purpose</h3>
<p>Prepare message data to normalize line breaks and escaping lines that contain single dots.</p>
<h3>Usage</h3>
<p>Call this function if the message data you want to send may contain line breaks that are not the &quot;\r\n&quot; sequence or it may contain lines that just have a single dot.</p>
<h3>Arguments</h3>
<ul>
<p><tt><b><a name="argument_PrepareData_data">data</a></b></tt> - Message data to be prepared.</p>
</ul>
<h3>Return value</h3>
<p>Resulting normalized messages data.</p>
<p><a href="#functions">Functions</a></p>
<h3><a name="function_SendData"></a><li><a name="15.2.16">SendData</a></li></h3>
<h3>Synopsis</h3>
<p><tt><i>bool</i> SendData(</tt><ul>
<tt><i>string</i> </tt><tt><a href="#argument_SendData_data">data</a></tt></ul>
<tt>)</tt></p>
<h3>Purpose</h3>
<p>Send message data.</p>
<h3>Usage</h3>
<p>Call this function repeatedly for all message data blocks to be sent right after start sending message data with the <tt><a href="#function_StartData">StartData</a></tt> function.</p>
<h3>Arguments</h3>
<ul>
<p><tt><b><a name="argument_SendData_data">data</a></b></tt> - Message data to be sent.</p>
</ul>
<h3>Return value</h3>
<p>The function returns <tt>1</tt> if the message data was sent to the SMTP server successfully.</p>
<p><a href="#functions">Functions</a></p>
<h3><a name="function_EndSendingData"></a><li><a name="17.2.17">EndSendingData</a></li></h3>
<h3>Synopsis</h3>
<p><tt><i>bool</i> EndSendingData(</tt><tt>)</tt></p>
<h3>Purpose</h3>
<p>Tell the server that all the message data was sent.</p>
<h3>Usage</h3>
<p>Call this function when you are done with sending the message data with the <tt><a href="#function_SendData">SendData</a></tt> function.</p>
<h3>Return value</h3>
<p>The function returns <tt>1</tt> if the server accepted the message.</p>
<p><a href="#functions">Functions</a></p>
<h3><a name="function_ResetConnection"></a><li><a name="17.2.18">ResetConnection</a></li></h3>
<h3>Synopsis</h3>
<p><tt><i>bool</i> ResetConnection(</tt><tt>)</tt></p>
<h3>Purpose</h3>
<p>Reset an already established SMTP connection to the initial state.</p>
<h3>Usage</h3>
<p>Call this function when there was an error sending a message and you need to skip to sending another message without disconnecting.</p>
<h3>Return value</h3>
<p>The function returns <tt>1</tt> if the connection was resetted successfully.</p>
<p><a href="#functions">Functions</a></p>
<h3><a name="function_Disconnect"></a><li><a name="17.2.19">Disconnect</a></li></h3>
<h3>Synopsis</h3>
<p><tt><i>bool</i> Disconnect(</tt><ul>
<tt><i>bool</i> </tt><tt><a href="#argument_Disconnect_quit">quit</a></tt> [default 1]</ul>
<tt>)</tt></p>
<h3>Purpose</h3>
<p>Terminate a previously opened connection.</p>
<h3>Usage</h3>
<p>Call this function after you are done sending your messages.</p>
<h3>Arguments</h3>
<ul>
<p><tt><b><a name="argument_Disconnect_quit">quit</a></b></tt> - Boolean option that tells whether the class should perform the final connection quit handshake, or just close the connection without waiting.</p>
</ul>
<h3>Return value</h3>
<p>The function returns <tt>1</tt> if the connection was successfully closed.</p>
<p><a href="#functions">Functions</a></p>
<h3><a name="function_SendMessage"></a><li><a name="19.2.20">SendMessage</a></li></h3>
<h3>Synopsis</h3>
<p><tt><i>bool</i> SendMessage(</tt><ul>
<tt><i>string</i> </tt><tt><a href="#argument_SendMessage_sender">sender</a></tt><tt>,</tt><br />
<tt><i>string</i> </tt><tt><a href="#argument_SendMessage_recipients">recipients</a></tt><tt>,</tt><br />
<tt>(input and output) <i>array</i> </tt><tt><a href="#argument_SendMessage_headers">headers</a></tt><tt>,</tt><br />
<tt><i>string</i> </tt><tt><a href="#argument_SendMessage_body">body</a></tt></ul>
<tt>)</tt></p>
<h3>Purpose</h3>
<p>Send a message in a single call.</p>
<h3>Usage</h3>
<p>Call this function if you want to send a single messages to a small number of recipients in a single call.</p>
<h3>Arguments</h3>
<ul>
<p><tt><b><a name="argument_SendMessage_sender">sender</a></b></tt> - E-mail address of the sender.</p>
<p><tt><b><a name="argument_SendMessage_recipients">recipients</a></b></tt> - Array with a list of the e-mail addresses of the recipients of the message.</p>
<p><tt><b><a name="argument_SendMessage_headers">headers</a></b></tt> - Array with a list of the header lines of the message.</p>
<p><tt><b><a name="argument_SendMessage_body">body</a></b></tt> - Body data of the message.</p>
</ul>
<h3>Return value</h3>
<p>The function returns <tt>1</tt> if the message was sent successfully.</p>
<p><a href="#functions">Functions</a></p>
<p><a href="#table_of_contents">Table of contents</a></p>
</ul>
</ul>
<hr />
<address>Manuel Lemos (<a href="mailto:mlemos-at-acm.org">mlemos-at-acm.org</a>)</address>
</body>
</html>

View file

@ -0,0 +1,477 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Class: MIME E-mail message composing and sending via SMTP</title>
</head>
<body>
<center><h1>Class: MIME E-mail message composing and sending via SMTP</h1></center>
<hr />
<ul>
<p><b>Version:</b> <tt>@(#) $Id: smtp_message_class.html,v 1.1 2014/03/03 12:28:32 horst Exp $</tt></p>
<h2><a name="table_of_contents">Contents</a></h2>
<ul>
<li><a href="#2.1.1">Summary</a></li>
<ul>
<li><a href="#3.2.0">Name</a></li>
<li><a href="#3.2.0.0">Author</a></li>
<li><a href="#3.2.0.1">Copyright</a></li>
<li><a href="#3.2.0.2">Version</a></li>
<li><a href="#3.2.0.3">Parent classes</a></li>
<li><a href="#4.2.0">Purpose</a></li>
<li><a href="#4.2.0.0">Usage</a></li>
</ul>
<li><a href="#5.1.1">Variables</a></li>
<ul>
<li><a href="#6.2.27">localhost</a></li>
<li><a href="#6.2.28">smtp_host</a></li>
<li><a href="#6.2.29">smtp_port</a></li>
<li><a href="#6.2.30">smtp_ssl</a></li>
<li><a href="#6.2.31">smtp_start_tls</a></li>
<li><a href="#6.2.32">smtp_http_proxy_host_name</a></li>
<li><a href="#6.2.33">smtp_http_proxy_host_port</a></li>
<li><a href="#6.2.34">smtp_socks_host_name</a></li>
<li><a href="#6.2.35">smtp_socks_host_port</a></li>
<li><a href="#6.2.36">smtp_socks_version</a></li>
<li><a href="#6.2.37">smtp_direct_delivery</a></li>
<li><a href="#6.2.38">smtp_getmxrr</a></li>
<li><a href="#6.2.39">smtp_exclude_address</a></li>
<li><a href="#6.2.40">smtp_user</a></li>
<li><a href="#6.2.41">smtp_realm</a></li>
<li><a href="#6.2.42">smtp_workstation</a></li>
<li><a href="#6.2.43">smtp_authentication_mechanism</a></li>
<li><a href="#6.2.44">smtp_password</a></li>
<li><a href="#6.2.45">smtp_pop3_auth_host</a></li>
<li><a href="#6.2.46">smtp_debug</a></li>
<li><a href="#6.2.47">smtp_html_debug</a></li>
<li><a href="#6.2.48">esmtp</a></li>
<li><a href="#6.2.49">timeout</a></li>
<li><a href="#6.2.50">invalid_recipients</a></li>
<li><a href="#6.2.51">mailer_delivery</a></li>
<li><a href="#6.2.52">maximum_bulk_deliveries</a></li>
</ul>
<li><a href="#7.1.1">Inherited variables</a></li>
<li><a href="#9.1.1">Functions</a></li>
<li><a href="#11.1.1">Inherited functions</a></li>
</ul>
<p><a href="#table_of_contents">Top of the table of contents</a></p>
</ul>
<hr />
<ul>
<h2><li><a name="2.1.1">Summary</a></li></h2>
<ul>
<h3><a name="3.2.0">Name</a></h3>
<p>MIME E-mail message composing and sending via SMTP</p>
<h3><a name="3.2.0.0">Author</a></h3>
<p>Manuel Lemos (<a href="mailto:mlemos-at-acm.org">mlemos-at-acm.org</a>)</p>
<h3><a name="3.2.0.1">Copyright</a></h3>
<p>Copyright &copy; (C) Manuel Lemos 1999-2004</p>
<h3><a name="3.2.0.2">Version</a></h3>
<p>@(#) $Id: smtp_message_class.html,v 1.1 2014/03/03 12:28:32 horst Exp $</p>
<h3><a name="3.2.0.3">Parent classes</a></h3>
<ul>
<p><li>MIME E-mail message composing and sending</li></p>
<p><b>Version:</b> <tt>@(#) $Id: smtp_message_class.html,v 1.1 2014/03/03 12:28:32 horst Exp $</tt></p>
</ul>
<h3><a name="4.2.0">Purpose</a></h3>
<p>Implement an alternative message delivery method via SMTP protocol, overriding the method of using the PHP <tt>mail()</tt> function implemented by the base class.</p>
<h3><a name="4.2.0.0">Usage</a></h3>
<p>This class should be used exactly the same way as the base class for composing and sending messages. Just create a new object of this class as follows and set only the necessary variables to configure details of the SMTP delivery.</p>
<p> <tt>require('email_message.php');<br />
require('smtp.php');<br />
require('smtp_message.php');<br />
<br />
$message_object = new smtp_message_class;<br />
</tt></p>
<p> <b>- Requirements</b></p>
<p> You need the <a href="http://freshmeat.net/projects/smtpclass/">SMTP E-mail sending class</a> to perform the actual message delivery via the SMTP protocol.</p>
<p> <b>- SMTP connection</b></p>
<p> Before sending a message by relaying it to a given SMTP server you need set the <tt><a href="#variable_smtp_host">smtp_host</a></tt> variable to that server address. The <tt><a href="#variable_localhost">localhost</a></tt> variable needs to be set to the sending computer address.</p>
<p> You may also adjust the time the class will wait for establishing a connection by changing the <tt><a href="#variable_timeout">timeout</a></tt> variable.</p>
<p> <b>- Secure SMTP connections with SSL</b></p>
<p> Some SMTP servers, like for instance Gmail, require secure connections via SSL. In that case it is necessary to set the <tt><a href="#variable_smtp_ssl">smtp_ssl</a></tt> variable to 1. In the case of Gmail, it is also necessary to set the connection port changing the <tt><a href="#variable_smtp_port">smtp_port</a></tt> variable to 465.</p>
<p> SSL support requires at least PHP 4.3.0 with OpenSSL extension enabled.</p>
<p> <b>- Secure SMTP connections starting TLS after connections is established</b></p>
<p> Some SMTP servers, like for instance Hotmail, require starting the TLS protocol after the connection is already established to exchange data securely. In that case it is necessary to set the <tt><a href="#variable_smtp_start_tls">smtp_start_tls</a></tt> variable to 1.</p>
<p> Starting TLS protocol on an already established connection requires at least PHP 5.1.0 with OpenSSL extension enabled.</p>
<p> <b>- Authentication</b></p>
<p> Most servers only allow relaying messages sent by authorized users. If the SMTP server that you want to use requires authentication, you need to set the variables <tt><a href="#variable_smtp_user">smtp_user</a></tt>, <tt><a href="#variable_smtp_realm">smtp_realm</a></tt> and <tt><a href="#variable_smtp_password">smtp_password</a></tt>.</p>
<p> The way these values need to be set depends on the server. Usually the realm value is empty and only the user and password need to be set. If the server requires authentication via <tt>NTLM</tt> mechanism (Windows or Samba), you need to set the <tt><a href="#variable_smtp_realm">smtp_realm</a></tt> to the Windows domain name and also set the variable <tt><a href="#variable_smtp_workstation">smtp_workstation</a></tt> to the user workstation name.</p>
<p> Some servers require that the authentication be done on a separate server using the POP3 protocol before connecting to the SMTP server. In this case you need to specify the address of the POP3 server setting the <tt><a href="#variable_smtp_pop3_auth_host">smtp_pop3_auth_host</a></tt> variable.</p>
<p> <b>- Sending urgent messages with direct delivery</b></p>
<p> If you need to send urgent messages or obtain immediate confirmation that a message is accepted by the recipient SMTP server, you can use the direct delivery mode setting the <tt><a href="#variable_direct_delivery">direct_delivery</a></tt> variable to <tt>1</tt>. This mode can be used to send a message to only one recipient.</p>
<p> To use this mode, it is necessary to have a way to determine the recipient domain SMTP server address. The class uses the PHP <tt>getmxrr()</tt> function, but on some systems like for instance under Windows, this function does not work. In this case you may specify an equivalent alternative by setting the <tt><a href="#variable_smtp_getmxrr">smtp_getmxrr</a></tt> variable. See the SMTP class page for available alternatives.</p>
<p> <b>- Troubleshooting and debugging</b></p>
<p> If for some reason the delivery via SMTP is not working and the error messages are not self-explanatory, you may set the <tt><a href="#variable_smtp_debug">smtp_debug</a></tt> to <tt>1</tt> to make the class output the SMTP protocol dialog with the server. If you want to display this dialog properly formatted in an HTML page, also set the <tt><a href="#variable_smtp_debug">smtp_debug</a></tt> to <tt>1</tt>.</p>
<p> <b>- Optimizing the delivery of messages to many recipients</b></p>
<p> When sending messages to many recipients, this class can hinted to optimize its behavior by using the <tt><a href="#function_SetBulkMail">SetBulkMail</a></tt> function. After calling this function passing 1 to the <tt><a href="#argument_SetBulkMail_on">on</a></tt> argument, when the message is sent this class opens a TCP connection to the SMTP server but will not close it. This avoids the overhead of opening and closing connections.</p>
<p> When the delivery of the messages to all recipients is done, the connection may be closed implicitly by calling the <tt><a href="#function_SetBulkMail">SetBulkMail</a></tt> function again passing 0 to the <tt><a href="#argument_SetBulkMail_on">on</a></tt> argument.</p>
<p><a href="#table_of_contents">Table of contents</a></p>
</ul>
</ul>
<hr />
<ul>
<h2><li><a name="variables"></a><a name="5.1.1">Variables</a></li></h2>
<ul>
<li><tt><a href="#variable_localhost">localhost</a></tt></li><br />
<li><tt><a href="#variable_smtp_host">smtp_host</a></tt></li><br />
<li><tt><a href="#variable_smtp_port">smtp_port</a></tt></li><br />
<li><tt><a href="#variable_smtp_ssl">smtp_ssl</a></tt></li><br />
<li><tt><a href="#variable_smtp_start_tls">smtp_start_tls</a></tt></li><br />
<li><tt><a href="#variable_smtp_http_proxy_host_name">smtp_http_proxy_host_name</a></tt></li><br />
<li><tt><a href="#variable_smtp_http_proxy_host_port">smtp_http_proxy_host_port</a></tt></li><br />
<li><tt><a href="#variable_smtp_socks_host_name">smtp_socks_host_name</a></tt></li><br />
<li><tt><a href="#variable_smtp_socks_host_port">smtp_socks_host_port</a></tt></li><br />
<li><tt><a href="#variable_smtp_socks_version">smtp_socks_version</a></tt></li><br />
<li><tt><a href="#variable_smtp_direct_delivery">smtp_direct_delivery</a></tt></li><br />
<li><tt><a href="#variable_smtp_getmxrr">smtp_getmxrr</a></tt></li><br />
<li><tt><a href="#variable_smtp_exclude_address">smtp_exclude_address</a></tt></li><br />
<li><tt><a href="#variable_smtp_user">smtp_user</a></tt></li><br />
<li><tt><a href="#variable_smtp_realm">smtp_realm</a></tt></li><br />
<li><tt><a href="#variable_smtp_workstation">smtp_workstation</a></tt></li><br />
<li><tt><a href="#variable_smtp_authentication_mechanism">smtp_authentication_mechanism</a></tt></li><br />
<li><tt><a href="#variable_smtp_password">smtp_password</a></tt></li><br />
<li><tt><a href="#variable_smtp_pop3_auth_host">smtp_pop3_auth_host</a></tt></li><br />
<li><tt><a href="#variable_smtp_debug">smtp_debug</a></tt></li><br />
<li><tt><a href="#variable_smtp_html_debug">smtp_html_debug</a></tt></li><br />
<li><tt><a href="#variable_esmtp">esmtp</a></tt></li><br />
<li><tt><a href="#variable_timeout">timeout</a></tt></li><br />
<li><tt><a href="#variable_invalid_recipients">invalid_recipients</a></tt></li><br />
<li><tt><a href="#variable_mailer_delivery">mailer_delivery</a></tt></li><br />
<li><tt><a href="#variable_maximum_bulk_deliveries">maximum_bulk_deliveries</a></tt></li><br />
<p><a href="#table_of_contents">Table of contents</a></p>
<h3><a name="variable_localhost"></a><li><a name="6.2.27">localhost</a></li></h3>
<h3>Type</h3>
<p><tt><i>string</i></tt></p>
<h3>Default value</h3>
<p><tt>''</tt></p>
<h3>Purpose</h3>
<p>Specify the domain name of the computer sending the message.</p>
<h3>Usage</h3>
<p>This value is used to identify the sending machine to the SMTP server. When using the direct delivery mode, if this variable is set to a non-empty string it used to generate the <tt>Recieved</tt> header to show that the message passed by the specified host address. To prevent confusing directly delivered messages with spam, it is strongly recommended that you set this variable to you server host name.</p>
<p><a href="#variables">Variables</a></p>
<h3><a name="variable_smtp_host"></a><li><a name="6.2.28">smtp_host</a></li></h3>
<h3>Type</h3>
<p><tt><i>string</i></tt></p>
<h3>Default value</h3>
<p><tt>''</tt></p>
<h3>Purpose</h3>
<p>Specify the address of the SMTP server.</p>
<h3>Usage</h3>
<p>Set to the address of the SMTP server that will relay the messages. This variable is not used in direct delivery mode.</p>
<p><a href="#variables">Variables</a></p>
<h3><a name="variable_smtp_port"></a><li><a name="6.2.29">smtp_port</a></li></h3>
<h3>Type</h3>
<p><tt><i>int</i></tt></p>
<h3>Default value</h3>
<p><tt>25</tt></p>
<h3>Purpose</h3>
<p>Specify the TCP/IP port of SMTP server to connect.</p>
<h3>Usage</h3>
<p>Most servers work on port 25 . Certain e-mail services use alternative ports to avoid firewall blocking. Gmail uses port 465.</p>
<p><a href="#variables">Variables</a></p>
<h3><a name="variable_smtp_ssl"></a><li><a name="6.2.30">smtp_ssl</a></li></h3>
<h3>Type</h3>
<p><tt><i>bool</i></tt></p>
<h3>Default value</h3>
<p><tt>0</tt></p>
<h3>Purpose</h3>
<p>Specify whether it should use secure connections with SSL to connect to the SMTP server.</p>
<h3>Usage</h3>
<p>Certain e-mail services like Gmail require SSL connections.</p>
<p><a href="#variables">Variables</a></p>
<h3><a name="variable_smtp_start_tls"></a><li><a name="6.2.31">smtp_start_tls</a></li></h3>
<h3>Type</h3>
<p><tt><i>bool</i></tt></p>
<h3>Default value</h3>
<p><tt>0</tt></p>
<h3>Purpose</h3>
<p>Specify whether it should use secure connections starting TLS protocol after connecting to the SMTP server.</p>
<h3>Usage</h3>
<p>Certain e-mail services like Hotmail require starting TLS protocol after the connection to the SMTP server is already established.</p>
<p><a href="#variables">Variables</a></p>
<h3><a name="variable_smtp_http_proxy_host_name"></a><li><a name="6.2.32">smtp_http_proxy_host_name</a></li></h3>
<h3>Type</h3>
<p><tt><i>string</i></tt></p>
<h3>Default value</h3>
<p><tt>''</tt></p>
<h3>Purpose</h3>
<p>Specify name of the host when the connection should be routed via an HTTP proxy.</p>
<h3>Usage</h3>
<p>Leave empty if no proxy should be used.</p>
<p><a href="#variables">Variables</a></p>
<h3><a name="variable_smtp_http_proxy_host_port"></a><li><a name="6.2.33">smtp_http_proxy_host_port</a></li></h3>
<h3>Type</h3>
<p><tt><i>int</i></tt></p>
<h3>Default value</h3>
<p><tt>3128</tt></p>
<h3>Purpose</h3>
<p>Specify proxy port when the connection should be routed via an HTTP proxy.</p>
<h3>Usage</h3>
<p>Change this variable if you need to use a proxy with a specific port.</p>
<p><a href="#variables">Variables</a></p>
<h3><a name="variable_smtp_socks_host_name"></a><li><a name="6.2.34">smtp_socks_host_name</a></li></h3>
<h3>Type</h3>
<p><tt><i>string</i></tt></p>
<h3>Default value</h3>
<p><tt>''</tt></p>
<h3>Purpose</h3>
<p>Specify name of the host when the connection should be routed via a SOCKS protocol proxy.</p>
<h3>Usage</h3>
<p>Leave empty if no proxy should be used.</p>
<p><a href="#variables">Variables</a></p>
<h3><a name="variable_smtp_socks_host_port"></a><li><a name="6.2.35">smtp_socks_host_port</a></li></h3>
<h3>Type</h3>
<p><tt><i>int</i></tt></p>
<h3>Default value</h3>
<p><tt>1080</tt></p>
<h3>Purpose</h3>
<p>Specify proxy port when the connection should be routed via a SOCKS protocol proxy.</p>
<h3>Usage</h3>
<p>Change this variable if you need to use a proxy with a specific port.</p>
<p><a href="#variables">Variables</a></p>
<h3><a name="variable_smtp_socks_version"></a><li><a name="6.2.36">smtp_socks_version</a></li></h3>
<h3>Type</h3>
<p><tt><i>string</i></tt></p>
<h3>Default value</h3>
<p><tt>''</tt></p>
<h3>Purpose</h3>
<p>Specify protocol version when the connection should be routed via a SOCKS protocol proxy.</p>
<h3>Usage</h3>
<p>Change this variable if you need to use a proxy with a specific SOCKS protocol version.</p>
<p><a href="#variables">Variables</a></p>
<h3><a name="variable_smtp_direct_delivery"></a><li><a name="6.2.37">smtp_direct_delivery</a></li></h3>
<h3>Type</h3>
<p><tt><i>bool</i></tt></p>
<h3>Default value</h3>
<p><tt>0</tt></p>
<h3>Purpose</h3>
<p>Boolean flag that indicates whether the message should be sent in direct delivery mode.</p>
<h3>Usage</h3>
<p>Set this to <tt>1</tt> if you want to send urgent messages directly to the recipient domain SMTP server.</p>
<p><a href="#variables">Variables</a></p>
<h3><a name="variable_smtp_getmxrr"></a><li><a name="6.2.38">smtp_getmxrr</a></li></h3>
<h3>Type</h3>
<p><tt><i>string</i></tt></p>
<h3>Default value</h3>
<p><tt>'getmxrr'</tt></p>
<h3>Purpose</h3>
<p>Specify the name of the function that is called to determine the SMTP server address of a given domain.</p>
<h3>Usage</h3>
<p>Change this to a working replacement of the PHP <tt>getmxrr()</tt> function if this is not working in your system and you want to send messages in direct delivery mode.</p>
<p><a href="#variables">Variables</a></p>
<h3><a name="variable_smtp_exclude_address"></a><li><a name="6.2.39">smtp_exclude_address</a></li></h3>
<h3>Type</h3>
<p><tt><i>string</i></tt></p>
<h3>Default value</h3>
<p><tt>''</tt></p>
<h3>Purpose</h3>
<p>Specify an address that should be considered invalid when resolving host name addresses.</p>
<h3>Usage</h3>
<p>In some networks any domain name that does not exist is resolved as a sub-domain of the default local domain. If the DNS is configured in such way that it always resolves any sub-domain of the default local domain to a given address, it is hard to determine whether a given domain does not exist.</p>
<p> If your network is configured this way, you may set this variable to the address that all sub-domains of the default local domain resolves, so the class can assume that such address is invalid.</p>
<p><a href="#variables">Variables</a></p>
<h3><a name="variable_smtp_user"></a><li><a name="6.2.40">smtp_user</a></li></h3>
<h3>Type</h3>
<p><tt><i>string</i></tt></p>
<h3>Default value</h3>
<p><tt>''</tt></p>
<h3>Purpose</h3>
<p>Specify the user name for authentication.</p>
<h3>Usage</h3>
<p>Set this variable if you need to authenticate before sending a message.</p>
<p><a href="#variables">Variables</a></p>
<h3><a name="variable_smtp_realm"></a><li><a name="6.2.41">smtp_realm</a></li></h3>
<h3>Type</h3>
<p><tt><i>string</i></tt></p>
<h3>Default value</h3>
<p><tt>''</tt></p>
<h3>Purpose</h3>
<p>Specify the user authentication realm.</p>
<h3>Usage</h3>
<p>Set this variable if you need to authenticate before sending a message.</p>
<p><a href="#variables">Variables</a></p>
<h3><a name="variable_smtp_workstation"></a><li><a name="6.2.42">smtp_workstation</a></li></h3>
<h3>Type</h3>
<p><tt><i>string</i></tt></p>
<h3>Default value</h3>
<p><tt>''</tt></p>
<h3>Purpose</h3>
<p>Specify the user authentication workstation needed when using the <tt>NTLM</tt> authentication (Windows or Samba).</p>
<h3>Usage</h3>
<p>Set this variable if you need to authenticate before sending a message.</p>
<p><a href="#variables">Variables</a></p>
<h3><a name="variable_smtp_authentication_mechanism"></a><li><a name="6.2.43">smtp_authentication_mechanism</a></li></h3>
<h3>Type</h3>
<p><tt><i>string</i></tt></p>
<h3>Default value</h3>
<p><tt>''</tt></p>
<h3>Purpose</h3>
<p>Specify the user authentication mechanism that should be used when authenticating with the SMTP server.</p>
<h3>Usage</h3>
<p>Set this variable if you need to force the SMTP connection to authenticate with a specific authentication mechanism. Leave this variable with an empty string if you want the authentication mechanism be determined automatically from the list of mechanisms supported by the server.</p>
<p><a href="#variables">Variables</a></p>
<h3><a name="variable_smtp_password"></a><li><a name="6.2.44">smtp_password</a></li></h3>
<h3>Type</h3>
<p><tt><i>string</i></tt></p>
<h3>Default value</h3>
<p><tt>''</tt></p>
<h3>Purpose</h3>
<p>Specify the user authentication password.</p>
<h3>Usage</h3>
<p>Set this variable if you need to authenticate before sending a message.</p>
<p><a href="#variables">Variables</a></p>
<h3><a name="variable_smtp_pop3_auth_host"></a><li><a name="6.2.45">smtp_pop3_auth_host</a></li></h3>
<h3>Type</h3>
<p><tt><i>string</i></tt></p>
<h3>Default value</h3>
<p><tt>''</tt></p>
<h3>Purpose</h3>
<p>Specify the server address for POP3 based authentication.</p>
<h3>Usage</h3>
<p>Set this variable to the address of the POP3 server if the SMTP server requires POP3 based authentication.</p>
<p><a href="#variables">Variables</a></p>
<h3><a name="variable_smtp_debug"></a><li><a name="6.2.46">smtp_debug</a></li></h3>
<h3>Type</h3>
<p><tt><i>bool</i></tt></p>
<h3>Default value</h3>
<p><tt>0</tt></p>
<h3>Purpose</h3>
<p>Specify whether it is necessary to output SMTP connection debug information.</p>
<h3>Usage</h3>
<p>Set this variable to <tt>1</tt> if you need to see the progress of the SMTP connection and protocol dialog when you need to understand the reason for delivery problems.</p>
<p><a href="#variables">Variables</a></p>
<h3><a name="variable_smtp_html_debug"></a><li><a name="6.2.47">smtp_html_debug</a></li></h3>
<h3>Type</h3>
<p><tt><i>bool</i></tt></p>
<h3>Default value</h3>
<p><tt>0</tt></p>
<h3>Purpose</h3>
<p>Specify whether the debug information should be outputted in HTML format.</p>
<h3>Usage</h3>
<p>Set this variable to <tt>1</tt> if you need to see the debug output in a Web page.</p>
<p><a href="#variables">Variables</a></p>
<h3><a name="variable_esmtp"></a><li><a name="6.2.48">esmtp</a></li></h3>
<h3>Type</h3>
<p><tt><i>bool</i></tt></p>
<h3>Default value</h3>
<p><tt>1</tt></p>
<h3>Purpose</h3>
<p>Specify whether the class should try to use Enhanced SMTP protocol features.</p>
<h3>Usage</h3>
<p>It is recommended to leave this variable set to <tt>1</tt> so the class can take advantage of Enhanced SMTP protocol features.</p>
<p><a href="#variables">Variables</a></p>
<h3><a name="variable_timeout"></a><li><a name="6.2.49">timeout</a></li></h3>
<h3>Type</h3>
<p><tt><i>int</i></tt></p>
<h3>Default value</h3>
<p><tt>25</tt></p>
<h3>Purpose</h3>
<p>Specify the connection timeout period in seconds.</p>
<h3>Usage</h3>
<p>Change this value if for some reason the timeout period seems insufficient or otherwise it seems too long.</p>
<p><a href="#variables">Variables</a></p>
<h3><a name="variable_invalid_recipients"></a><li><a name="6.2.50">invalid_recipients</a></li></h3>
<h3>Type</h3>
<p><tt><i>array</i></tt></p>
<h3>Default value</h3>
<p><tt>array()</tt></p>
<h3>Purpose</h3>
<p>Return the list of recipient addresses that were not accepted by the SMTP server.</p>
<h3>Usage</h3>
<p>Check this variable after attempting to send a message to figure whether there were any recipients that were rejected by the SMTP server.</p>
<p><a href="#variables">Variables</a></p>
<h3><a name="variable_mailer_delivery"></a><li><a name="6.2.51">mailer_delivery</a></li></h3>
<h3>Type</h3>
<p><tt><i>string</i></tt></p>
<h3>Default value</h3>
<p><tt>'smtp $Revision: 1.1 $'</tt></p>
<h3>Purpose</h3>
<p>Specify the text that is used to identify the mail delivery class or sub-class. This text is appended to the <tt>X-Mailer</tt> header text defined by the mailer variable.</p>
<h3>Usage</h3>
<p>Do not change this variable.</p>
<p><a href="#variables">Variables</a></p>
<h3><a name="variable_maximum_bulk_deliveries"></a><li><a name="6.2.52">maximum_bulk_deliveries</a></li></h3>
<h3>Type</h3>
<p><tt><i>int</i></tt></p>
<h3>Default value</h3>
<p><tt>100</tt></p>
<h3>Purpose</h3>
<p>Specify the number of consecutive bulk mail deliveries without disconnecting.</p>
<h3>Usage</h3>
<p>Lower this value if you have enabled the bulk mail mode but the SMTP server does not accept sending more than a number of messages within the same SMTP connection.</p>
<p> Set this value to 0 to never disconnect during bulk mail mode unless an error occurs.</p>
<p><a href="#variables">Variables</a></p>
<p><a href="#table_of_contents">Table of contents</a></p>
</ul>
</ul>
<ul>
<h2><li><a name="functions"></a><a name="7.1.1">Inherited variables</a></li></h2>
<ul>
<li>email_regular_expression</li><br />
<li>mailer</li><br />
<li>default_charset</li><br />
<li>line_quote_prefix</li><br />
<li>break_long_lines</li><br />
<li>file_buffer_length</li><br />
<li>debug</li><br />
<li>cache_body</li><br />
<li>error</li><br />
<p><a href="#table_of_contents">Table of contents</a></p>
</ul>
</ul>
<hr />
<ul>
<h2><li><a name="functions"></a><a name="9.1.1">Functions</a></li></h2>
<ul>
<p><a href="#table_of_contents">Table of contents</a></p>
<p><a href="#table_of_contents">Table of contents</a></p>
</ul>
</ul>
<ul>
<h2><li><a name="functions"></a><a name="11.1.1">Inherited functions</a></li></h2>
<ul>
<li>ValidateEmailAddress</li><br />
<li>WrapText</li><br />
<li>CenterText</li><br />
<li>Ruler</li><br />
<li>QuoteText</li><br />
<li>SetHeader</li><br />
<li>SetEncodedHeader</li><br />
<li>SetEncodedEmailHeader</li><br />
<li>SetMultipleEncodedEmailHeader</li><br />
<li>ResetMessage</li><br />
<li>AddPart</li><br />
<li>ReplacePart</li><br />
<li>CreatePlainTextPart</li><br />
<li>AddPlainTextPart</li><br />
<li>CreateQuotedPrintableTextPart</li><br />
<li>AddQuotedPrintableTextPart</li><br />
<li>CreateHTMLPart</li><br />
<li>AddHTMLPart</li><br />
<li>CreateQuotedPrintableHTMLPart</li><br />
<li>AddQuotedPrintableHTMLPart</li><br />
<li>CreateFilePart</li><br />
<li>AddFilePart</li><br />
<li>CreateMessagePart</li><br />
<li>AddMessagePart</li><br />
<li>CreateAlternativeMultipart</li><br />
<li>AddAlternativeMultipart</li><br />
<li>CreateRelatedMultipart</li><br />
<li>AddRelatedMultipart</li><br />
<li>CreateMixedMultipart</li><br />
<li>AddMixedMultipart</li><br />
<li>GetPartContentID</li><br />
<li>GetDataURL</li><br />
<li>Send</li><br />
<li>GetMessage</li><br />
<li>GetMessageSize</li><br />
<li>Mail</li><br />
<li>SetBulkMail</li><br />
<p><a href="#table_of_contents">Table of contents</a></p>
</ul>
</ul>
<hr />
<address>Manuel Lemos (<a href="mailto:mlemos-at-acm.org">mlemos-at-acm.org</a>)</address>
</body>
</html>

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,69 @@
<?php
/*
* login_sasl_client.php
*
* @(#) $Id: login_sasl_client.php,v 1.2 2004/11/17 08:00:37 mlemos Exp $
*
*/
define("SASL_LOGIN_STATE_START", 0);
define("SASL_LOGIN_STATE_IDENTIFY_USER", 1);
define("SASL_LOGIN_STATE_IDENTIFY_PASSWORD", 2);
define("SASL_LOGIN_STATE_DONE", 3);
class login_sasl_client_class
{
var $credentials=array();
var $state=SASL_LOGIN_STATE_START;
Function Initialize(&$client)
{
return(1);
}
Function Start(&$client, &$message, &$interactions)
{
if($this->state!=SASL_LOGIN_STATE_START)
{
$client->error="LOGIN authentication state is not at the start";
return(SASL_FAIL);
}
$this->credentials=array(
"user"=>"",
"password"=>"",
"realm"=>""
);
$defaults=array(
"realm"=>""
);
$status=$client->GetCredentials($this->credentials,$defaults,$interactions);
if($status==SASL_CONTINUE)
$this->state=SASL_LOGIN_STATE_IDENTIFY_USER;
Unset($message);
return($status);
}
Function Step(&$client, $response, &$message, &$interactions)
{
switch($this->state)
{
case SASL_LOGIN_STATE_IDENTIFY_USER:
$message=$this->credentials["user"].(strlen($this->credentials["realm"]) ? "@".$this->credentials["realm"] : "");
$this->state=SASL_LOGIN_STATE_IDENTIFY_PASSWORD;
break;
case SASL_LOGIN_STATE_IDENTIFY_PASSWORD:
$message=$this->credentials["password"];
$this->state=SASL_LOGIN_STATE_DONE;
break;
case SASL_LOGIN_STATE_DONE:
$client->error="LOGIN authentication was finished without success";
break;
default:
$client->error="invalid LOGIN authentication step state";
return(SASL_FAIL);
}
return(SASL_CONTINUE);
}
};
?>

View file

@ -0,0 +1,180 @@
<?php
/*
* ntlm_sasl_client.php
*
* @(#) $Id: ntlm_sasl_client.php,v 1.3 2004/11/17 08:00:37 mlemos Exp $
*
*/
define("SASL_NTLM_STATE_START", 0);
define("SASL_NTLM_STATE_IDENTIFY_DOMAIN", 1);
define("SASL_NTLM_STATE_RESPOND_CHALLENGE", 2);
define("SASL_NTLM_STATE_DONE", 3);
class ntlm_sasl_client_class
{
var $credentials=array();
var $state=SASL_NTLM_STATE_START;
Function Initialize(&$client)
{
if(!function_exists($function="mcrypt_encrypt")
|| !function_exists($function="mhash"))
{
$extensions=array(
"mcrypt_encrypt"=>"mcrypt",
"mhash"=>"mhash"
);
$client->error="the extension ".$extensions[$function]." required by the NTLM SASL client class is not available in this PHP configuration";
return(0);
}
return(1);
}
Function ASCIIToUnicode($ascii)
{
for($unicode="",$a=0;$a<strlen($ascii);$a++)
$unicode.=substr($ascii,$a,1).chr(0);
return($unicode);
}
Function TypeMsg1($domain,$workstation)
{
$domain_length=strlen($domain);
$workstation_length=strlen($workstation);
$workstation_offset=32;
$domain_offset=$workstation_offset+$workstation_length;
return(
"NTLMSSP\0".
"\x01\x00\x00\x00".
"\x07\x32\x00\x00".
pack("v",$domain_length).
pack("v",$domain_length).
pack("V",$domain_offset).
pack("v",$workstation_length).
pack("v",$workstation_length).
pack("V",$workstation_offset).
$workstation.
$domain
);
}
Function NTLMResponse($challenge,$password)
{
$unicode=$this->ASCIIToUnicode($password);
$md4=mhash(MHASH_MD4,$unicode);
$padded=$md4.str_repeat(chr(0),21-strlen($md4));
$iv_size=mcrypt_get_iv_size(MCRYPT_DES,MCRYPT_MODE_ECB);
$iv=mcrypt_create_iv($iv_size,MCRYPT_RAND);
for($response="",$third=0;$third<21;$third+=7)
{
for($packed="",$p=$third;$p<$third+7;$p++)
$packed.=str_pad(decbin(ord(substr($padded,$p,1))),8,"0",STR_PAD_LEFT);
for($key="",$p=0;$p<strlen($packed);$p+=7)
{
$s=substr($packed,$p,7);
$b=$s.((substr_count($s,"1") % 2) ? "0" : "1");
$key.=chr(bindec($b));
}
$ciphertext=mcrypt_encrypt(MCRYPT_DES,$key,$challenge,MCRYPT_MODE_ECB,$iv);
$response.=$ciphertext;
}
return $response;
}
Function TypeMsg3($ntlm_response,$user,$domain,$workstation)
{
$domain_unicode=$this->ASCIIToUnicode($domain);
$domain_length=strlen($domain_unicode);
$domain_offset=64;
$user_unicode=$this->ASCIIToUnicode($user);
$user_length=strlen($user_unicode);
$user_offset=$domain_offset+$domain_length;
$workstation_unicode=$this->ASCIIToUnicode($workstation);
$workstation_length=strlen($workstation_unicode);
$workstation_offset=$user_offset+$user_length;
$lm="";
$lm_length=strlen($lm);
$lm_offset=$workstation_offset+$workstation_length;
$ntlm=$ntlm_response;
$ntlm_length=strlen($ntlm);
$ntlm_offset=$lm_offset+$lm_length;
$session="";
$session_length=strlen($session);
$session_offset=$ntlm_offset+$ntlm_length;
return(
"NTLMSSP\0".
"\x03\x00\x00\x00".
pack("v",$lm_length).
pack("v",$lm_length).
pack("V",$lm_offset).
pack("v",$ntlm_length).
pack("v",$ntlm_length).
pack("V",$ntlm_offset).
pack("v",$domain_length).
pack("v",$domain_length).
pack("V",$domain_offset).
pack("v",$user_length).
pack("v",$user_length).
pack("V",$user_offset).
pack("v",$workstation_length).
pack("v",$workstation_length).
pack("V",$workstation_offset).
pack("v",$session_length).
pack("v",$session_length).
pack("V",$session_offset).
"\x01\x02\x00\x00".
$domain_unicode.
$user_unicode.
$workstation_unicode.
$lm.
$ntlm
);
}
Function Start(&$client, &$message, &$interactions)
{
if($this->state!=SASL_NTLM_STATE_START)
{
$client->error="NTLM authentication state is not at the start";
return(SASL_FAIL);
}
$this->credentials=array(
"user"=>"",
"password"=>"",
"realm"=>"",
"workstation"=>""
);
$defaults=array();
$status=$client->GetCredentials($this->credentials,$defaults,$interactions);
if($status==SASL_CONTINUE)
$this->state=SASL_NTLM_STATE_IDENTIFY_DOMAIN;
Unset($message);
return($status);
}
Function Step(&$client, $response, &$message, &$interactions)
{
switch($this->state)
{
case SASL_NTLM_STATE_IDENTIFY_DOMAIN:
$message=$this->TypeMsg1($this->credentials["realm"],$this->credentials["workstation"]);
$this->state=SASL_NTLM_STATE_RESPOND_CHALLENGE;
break;
case SASL_NTLM_STATE_RESPOND_CHALLENGE:
$ntlm_response=$this->NTLMResponse(substr($response,24,8),$this->credentials["password"]);
$message=$this->TypeMsg3($ntlm_response,$this->credentials["user"],$this->credentials["realm"],$this->credentials["workstation"]);
$this->state=SASL_NTLM_STATE_DONE;
break;
case SASL_NTLM_STATE_DONE:
$client->error="NTLM authentication was finished without success";
return(SASL_FAIL);
default:
$client->error="invalid NTLM authentication step state";
return(SASL_FAIL);
}
return(SASL_CONTINUE);
}
};
?>

View file

@ -0,0 +1,99 @@
<?php
/*
* plain_sasl_client.php
*
* @(#) $Id: plain_sasl_client.php,v 1.2 2004/11/17 08:00:37 mlemos Exp $
*
*/
define("SASL_PLAIN_STATE_START", 0);
define("SASL_PLAIN_STATE_IDENTIFY", 1);
define("SASL_PLAIN_STATE_DONE", 2);
define("SASL_PLAIN_DEFAULT_MODE", 0);
define("SASL_PLAIN_EXIM_MODE", 1);
define("SASL_PLAIN_EXIM_DOCUMENTATION_MODE", 2);
class plain_sasl_client_class
{
var $credentials=array();
var $state=SASL_PLAIN_STATE_START;
Function Initialize(&$client)
{
return(1);
}
Function Start(&$client, &$message, &$interactions)
{
if($this->state!=SASL_PLAIN_STATE_START)
{
$client->error="PLAIN authentication state is not at the start";
return(SASL_FAIL);
}
$this->credentials=array(
"user"=>"",
"password"=>"",
"realm"=>"",
"mode"=>""
);
$defaults=array(
"realm"=>"",
"mode"=>""
);
$status=$client->GetCredentials($this->credentials,$defaults,$interactions);
if($status==SASL_CONTINUE)
{
switch($this->credentials["mode"])
{
case SASL_PLAIN_EXIM_MODE:
$message=$this->credentials["user"]."\0".$this->credentials["password"]."\0";
break;
case SASL_PLAIN_EXIM_DOCUMENTATION_MODE:
$message="\0".$this->credentials["user"]."\0".$this->credentials["password"];
break;
default:
$message=$this->credentials["user"]."\0".$this->credentials["user"].(strlen($this->credentials["realm"]) ? "@".$this->credentials["realm"] : "")."\0".$this->credentials["password"];
break;
}
$this->state=SASL_PLAIN_STATE_DONE;
}
else
Unset($message);
return($status);
}
Function Step(&$client, $response, &$message, &$interactions)
{
switch($this->state)
{
/*
case SASL_PLAIN_STATE_IDENTIFY:
switch($this->credentials["mode"])
{
case SASL_PLAIN_EXIM_MODE:
$message=$this->credentials["user"]."\0".$this->credentials["password"]."\0";
break;
case SASL_PLAIN_EXIM_DOCUMENTATION_MODE:
$message="\0".$this->credentials["user"]."\0".$this->credentials["password"];
break;
default:
$message=$this->credentials["user"]."\0".$this->credentials["user"].(strlen($this->credentials["realm"]) ? "@".$this->credentials["realm"] : "")."\0".$this->credentials["password"];
break;
}
var_dump($message);
$this->state=SASL_PLAIN_STATE_DONE;
break;
*/
case SASL_PLAIN_STATE_DONE:
$client->error="PLAIN authentication was finished without success";
return(SASL_FAIL);
default:
$client->error="invalid PLAIN authentication step state";
return(SASL_FAIL);
}
return(SASL_CONTINUE);
}
};
?>

View file

@ -0,0 +1,422 @@
<?php
/*
* sasl.php
*
* @(#) $Id: sasl.php,v 1.11 2005/10/31 18:43:27 mlemos Exp $
*
*/
define("SASL_INTERACT", 2);
define("SASL_CONTINUE", 1);
define("SASL_OK", 0);
define("SASL_FAIL", -1);
define("SASL_NOMECH", -4);
class sasl_interact_class
{
var $id;
var $challenge;
var $prompt;
var $default_result;
var $result;
};
/*
{metadocument}<?xml version="1.0" encoding="ISO-8859-1" ?>
<class>
<package>net.manuellemos.sasl</package>
<version>@(#) $Id: sasl.php,v 1.11 2005/10/31 18:43:27 mlemos Exp $</version>
<copyright>Copyright © (C) Manuel Lemos 2004</copyright>
<title>Simple Authentication and Security Layer client</title>
<author>Manuel Lemos</author>
<authoraddress>mlemos-at-acm.org</authoraddress>
<documentation>
<idiom>en</idiom>
<purpose>Provide a common interface to plug-in driver classes that
implement different mechanisms for authentication used by clients of
standard protocols like SMTP, POP3, IMAP, HTTP, etc.. Currently the
supported authentication mechanisms are: <tt>PLAIN</tt>,
<tt>LOGIN</tt>, <tt>CRAM-MD5</tt>, <tt>Digest</tt> and <tt>NTML</tt>
(Windows or Samba).</purpose>
<usage>.</usage>
</documentation>
{/metadocument}
*/
class sasl_client_class
{
/* Public variables */
/*
{metadocument}
<variable>
<name>error</name>
<type>STRING</type>
<value></value>
<documentation>
<purpose>Store the message that is returned when an error
occurs.</purpose>
<usage>Check this variable to understand what happened when a call to
any of the class functions has failed.<paragraphbreak />
This class uses cumulative error handling. This means that if one
class functions that may fail is called and this variable was
already set to an error message due to a failure in a previous call
to the same or other function, the function will also fail and does
not do anything.<paragraphbreak />
This allows programs using this class to safely call several
functions that may fail and only check the failure condition after
the last function call.<paragraphbreak />
Just set this variable to an empty string to clear the error
condition.</usage>
</documentation>
</variable>
{/metadocument}
*/
var $error='';
/*
{metadocument}
<variable>
<name>mechanism</name>
<type>STRING</type>
<value></value>
<documentation>
<purpose>Store the name of the mechanism that was selected during the
call to the <functionlink>Start</functionlink> function.</purpose>
<usage>You can access this variable but do not change it.</usage>
</documentation>
</variable>
{/metadocument}
*/
var $mechanism='';
/*
{metadocument}
<variable>
<name>encode_response</name>
<type>BOOLEAN</type>
<value>1</value>
<documentation>
<purpose>Let the drivers inform the applications whether responses
need to be encoded.</purpose>
<usage>Applications should check this variable before sending
authentication responses to the server to determine if the
responses need to be encoded, eventually with base64 algorithm.</usage>
</documentation>
</variable>
{/metadocument}
*/
var $encode_response=1;
/* Private variables */
var $driver;
var $drivers=array(
"Digest" => array("digest_sasl_client_class", "digest_sasl_client.php" ),
"CRAM-MD5" => array("cram_md5_sasl_client_class", "cram_md5_sasl_client.php" ),
"LOGIN" => array("login_sasl_client_class", "login_sasl_client.php" ),
"NTLM" => array("ntlm_sasl_client_class", "ntlm_sasl_client.php" ),
"PLAIN" => array("plain_sasl_client_class", "plain_sasl_client.php" ),
"Basic" => array("basic_sasl_client_class", "basic_sasl_client.php" )
);
var $credentials=array();
/* Public functions */
/*
{metadocument}
<function>
<name>SetCredential</name>
<type>VOID</type>
<documentation>
<purpose>Store the value of a credential that may be used by any of
the supported mechanisms to process the authentication messages and
responses.</purpose>
<usage>Call this function before starting the authentication dialog
to pass all the credential values that be needed to use the type
of authentication that the applications may need.</usage>
<returnvalue>.</returnvalue>
</documentation>
<argument>
<name>key</name>
<type>STRING</type>
<documentation>
<purpose>Specify the name of the credential key.</purpose>
</documentation>
</argument>
<argument>
<name>value</name>
<type>STRING</type>
<documentation>
<purpose>Specify the value for the credential.</purpose>
</documentation>
</argument>
<do>
{/metadocument}
*/
Function SetCredential($key,$value)
{
$this->credentials[$key]=$value;
}
/*
{metadocument}
</do>
</function>
{/metadocument}
*/
/*
{metadocument}
<function>
<name>GetCredentials</name>
<type>INTEGER</type>
<documentation>
<purpose>Retrieve the values of one or more credentials to be used by
the authentication mechanism classes.</purpose>
<usage>This is meant to be used by authentication mechanism driver
classes to retrieve the credentials that may be neede.</usage>
<returnvalue>The function may return <tt>SASL_CONTINUE</tt> if it
succeeded, or <tt>SASL_NOMECH</tt> if it was not possible to
retrieve one of the requested credentials.</returnvalue>
</documentation>
<argument>
<name>credentials</name>
<type>HASH</type>
<documentation>
<purpose>Reference to an associative array variable with all the
credentials that are being requested. The function initializes
this associative array values.</purpose>
</documentation>
</argument>
<argument>
<name>defaults</name>
<type>HASH</type>
<documentation>
<purpose>Associative arrays with default values for credentials
that may have not been defined.</purpose>
</documentation>
</argument>
<argument>
<name>interactions</name>
<type>ARRAY</type>
<documentation>
<purpose>Not yet in use. It is meant to provide context
information to retrieve credentials that may be obtained
interacting with the user.</purpose>
</documentation>
</argument>
<do>
{/metadocument}
*/
Function GetCredentials(&$credentials,$defaults,&$interactions)
{
Reset($credentials);
$end=(GetType($key=Key($credentials))!="string");
for(;!$end;)
{
if(!IsSet($this->credentials[$key]))
{
if(IsSet($defaults[$key]))
$credentials[$key]=$defaults[$key];
else
{
$this->error="the requested credential ".$key." is not defined";
return(SASL_NOMECH);
}
}
else
$credentials[$key]=$this->credentials[$key];
Next($credentials);
$end=(GetType($key=Key($credentials))!="string");
}
return(SASL_CONTINUE);
}
/*
{metadocument}
</do>
</function>
{/metadocument}
*/
/*
{metadocument}
<function>
<name>Start</name>
<type>INTEGER</type>
<documentation>
<purpose>Process the initial authentication step initializing the
driver class that implements the first of the list of requested
mechanisms that is supported by this SASL client library
implementation.</purpose>
<usage>Call this function specifying a list of mechanisms that the
server supports. If the <argumentlink>
<argument>message</argument>
<function>Start</function>
</argumentlink> argument returns a string, it should be sent to
the server as initial message. Check the
<variablelink>encode_response</variablelink> variable to determine
whether the initial message needs to be encoded, eventually with
base64 algorithm, before it is sent to the server.</usage>
<returnvalue>The function may return <tt>SASL_CONTINUE</tt> if it
could start one of the requested authentication mechanisms. It
may return <tt>SASL_NOMECH</tt> if it was not possible to start
any of the requested mechanisms. It returns <tt>SASL_FAIL</tt> or
other value in case of error.</returnvalue>
</documentation>
<argument>
<name>mechanisms</name>
<type>ARRAY</type>
<inout />
<documentation>
<purpose>Define the list of names of authentication mechanisms
supported by the that should be tried.</purpose>
</documentation>
</argument>
<argument>
<name>message</name>
<type>STRING</type>
<out />
<documentation>
<purpose>Return the initial message that should be sent to the
server to start the authentication dialog. If this value is
undefined, no message should be sent to the server.</purpose>
</documentation>
</argument>
<argument>
<name>interactions</name>
<type>ARRAY</type>
<documentation>
<purpose>Not yet in use. It is meant to provide context
information to interact with the end user.</purpose>
</documentation>
</argument>
<do>
{/metadocument}
*/
Function Start($mechanisms, &$message, &$interactions)
{
if(strlen($this->error))
return(SASL_FAIL);
if(IsSet($this->driver))
return($this->driver->Start($this,$message,$interactions));
$no_mechanism_error="";
for($m=0;$m<count($mechanisms);$m++)
{
$mechanism=$mechanisms[$m];
if(IsSet($this->drivers[$mechanism]))
{
if(!class_exists($this->drivers[$mechanism][0]))
require(dirname(__FILE__)."/".$this->drivers[$mechanism][1]);
$this->driver=new $this->drivers[$mechanism][0];
if($this->driver->Initialize($this))
{
$this->encode_response=1;
$status=$this->driver->Start($this,$message,$interactions);
switch($status)
{
case SASL_NOMECH:
Unset($this->driver);
if(strlen($no_mechanism_error)==0)
$no_mechanism_error=$this->error;
$this->error="";
break;
case SASL_CONTINUE:
$this->mechanism=$mechanism;
return($status);
default:
Unset($this->driver);
$this->error="";
return($status);
}
}
else
{
Unset($this->driver);
if(strlen($no_mechanism_error)==0)
$no_mechanism_error=$this->error;
$this->error="";
}
}
}
$this->error=(strlen($no_mechanism_error) ? $no_mechanism_error : "it was not requested any of the authentication mechanisms that are supported");
return(SASL_NOMECH);
}
/*
{metadocument}
</do>
</function>
{/metadocument}
*/
/*
{metadocument}
<function>
<name>Step</name>
<type>INTEGER</type>
<documentation>
<purpose>Process the authentication steps after the initial step,
until the authetication iteration dialog is complete.</purpose>
<usage>Call this function iteratively after a successful initial
step calling the <functionlink>Start</functionlink> function.</usage>
<returnvalue>The function returns <tt>SASL_CONTINUE</tt> if step was
processed successfully, or returns <tt>SASL_FAIL</tt> in case of
error.</returnvalue>
</documentation>
<argument>
<name>response</name>
<type>STRING</type>
<in />
<documentation>
<purpose>Pass the response returned by the server to the previous
step.</purpose>
</documentation>
</argument>
<argument>
<name>message</name>
<type>STRING</type>
<out />
<documentation>
<purpose>Return the message that should be sent to the server to
continue the authentication dialog. If this value is undefined,
no message should be sent to the server.</purpose>
</documentation>
</argument>
<argument>
<name>interactions</name>
<type>ARRAY</type>
<documentation>
<purpose>Not yet in use. It is meant to provide context
information to interact with the end user.</purpose>
</documentation>
</argument>
<do>
{/metadocument}
*/
Function Step($response, &$message, &$interactions)
{
if(strlen($this->error))
return(SASL_FAIL);
return($this->driver->Step($this,$response,$message,$interactions));
}
/*
{metadocument}
</do>
</function>
{/metadocument}
*/
};
/*
{metadocument}
</class>
{/metadocument}
*/
?>

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,803 @@
<?php
/*
* smtp_message.php
*
* @(#) $Header: /opt2/ena/metal/mimemessage/smtp_message.php,v 1.36 2011/03/09 07:48:52 mlemos Exp $
*
*
*/
/**
* @horst, 19.04.2019:
* added support for: smtp_tls_crypto_method
*
*
*/
/*
{metadocument}<?xml version="1.0" encoding="ISO-8859-1"?>
<class>
<package>net.manuellemos.mimemessage</package>
<name>smtp_message_class</name>
<version>@(#) $Id: smtp_message.php,v 1.36 2011/03/09 07:48:52 mlemos Exp $</version>
<copyright>Copyright © (C) Manuel Lemos 1999-2004</copyright>
<title>MIME E-mail message composing and sending via SMTP</title>
<author>Manuel Lemos</author>
<authoraddress>mlemos-at-acm.org</authoraddress>
<documentation>
<idiom>en</idiom>
<purpose>Implement an alternative message delivery method via SMTP
protocol, overriding the method of using the PHP <tt>mail()</tt>
function implemented by the base class.</purpose>
<usage>This class should be used exactly the same way as the base
class for composing and sending messages. Just create a new object of
this class as follows and set only the necessary variables to
configure details of the SMTP delivery.<paragraphbreak />
<tt>require('email_message.php');<br />
require('smtp.php');<br />
require('smtp_message.php');<br />
<br />
$message_object = new smtp_message_class;<br /></tt><paragraphbreak />
<b>- Requirements</b><paragraphbreak />
You need the <link>
<data>SMTP E-mail sending class</data>
<url>http://freshmeat.net/projects/smtpclass/</url>
</link> to perform the actual message delivery via the SMTP
protocol.<paragraphbreak />
<b>- SMTP connection</b><paragraphbreak />
Before sending a message by relaying it to a given SMTP server you
need set the <variablelink>smtp_host</variablelink> variable to that
server address. The <variablelink>localhost</variablelink> variable
needs to be set to the sending computer address.<paragraphbreak />
You may also adjust the time the class will wait for establishing
a connection by changing the <variablelink>timeout</variablelink>
variable.<paragraphbreak />
<b>- Secure SMTP connections with SSL</b><paragraphbreak />
Some SMTP servers, like for instance Gmail, require secure
connections via SSL. In that case it is necessary to set the
<variablelink>smtp_ssl</variablelink> variable to
<booleanvalue>1</booleanvalue>. In the case of Gmail, it is also
necessary to set the connection port changing the
<variablelink>smtp_port</variablelink> variable to
<integervalue>465</integervalue>.<paragraphbreak />
SSL support requires at least PHP 4.3.0 with OpenSSL extension
enabled.<paragraphbreak />
<b>- Secure SMTP connections starting TLS after connections is established</b><paragraphbreak />
Some SMTP servers, like for instance Hotmail, require starting the
TLS protocol after the connection is already established to exchange
data securely. In that case it is necessary to set the
<variablelink>smtp_start_tls</variablelink> variable to
<booleanvalue>1</booleanvalue>.<paragraphbreak />
Starting TLS protocol on an already established connection requires
at least PHP 5.1.0 with OpenSSL extension enabled.<paragraphbreak />
<b>- Authentication</b><paragraphbreak />
Most servers only allow relaying messages sent by authorized
users. If the SMTP server that you want to use requires
authentication, you need to set the variables
<variablelink>smtp_user</variablelink>,
<variablelink>smtp_realm</variablelink> and
<variablelink>smtp_password</variablelink>.<paragraphbreak />
The way these values need to be set depends on the server. Usually
the realm value is empty and only the user and password need to be
set. If the server requires authentication via <tt>NTLM</tt>
mechanism (Windows or Samba), you need to set the
<variablelink>smtp_realm</variablelink> to the Windows domain name
and also set the variable
<variablelink>smtp_workstation</variablelink> to the user workstation
name.<paragraphbreak />
Some servers require that the authentication be done on a separate
server using the POP3 protocol before connecting to the SMTP server.
In this case you need to specify the address of the POP3 server
setting the <variablelink>smtp_pop3_auth_host</variablelink>
variable.<paragraphbreak />
<b>- Sending urgent messages with direct delivery</b><paragraphbreak />
If you need to send urgent messages or obtain immediate confirmation
that a message is accepted by the recipient SMTP server, you can use
the direct delivery mode setting the
<variablelink>direct_delivery</variablelink> variable to
<tt><booleanvalue>1</booleanvalue></tt>. This mode can be used to
send a message to only one recipient.<paragraphbreak />
To use this mode, it is necessary to have a way to determine the
recipient domain SMTP server address. The class uses the PHP
<tt>getmxrr()</tt> function, but on some systems like for instance
under Windows, this function does not work. In this case you may
specify an equivalent alternative by setting the
<variablelink>smtp_getmxrr</variablelink> variable. See the SMTP
class page for available alternatives.<paragraphbreak />
<b>- Troubleshooting and debugging</b><paragraphbreak />
If for some reason the delivery via SMTP is not working and the error
messages are not self-explanatory, you may set the
<variablelink>smtp_debug</variablelink> to
<tt><booleanvalue>1</booleanvalue></tt> to make the class output the
SMTP protocol dialog with the server. If you want to display this
dialog properly formatted in an HTML page, also set the
<variablelink>smtp_debug</variablelink> to
<tt><booleanvalue>1</booleanvalue></tt>.<paragraphbreak />
<b>- Optimizing the delivery of messages to many recipients</b><paragraphbreak />
When sending messages to many recipients, this class can hinted to
optimize its behavior by using the
<functionlink>SetBulkMail</functionlink> function. After calling this
function passing <booleanvalue>1</booleanvalue> to the <argumentlink>
<function>SetBulkMail</function>
<argument>on</argument>
</argumentlink> argument, when the message is sent this class opens
a TCP connection to the SMTP server but will not close it. This
avoids the overhead of opening and closing connections.<paragraphbreak />
When the delivery of the messages to all recipients is done, the
connection may be closed implicitly by calling the
<functionlink>SetBulkMail</functionlink> function again passing
<booleanvalue>0</booleanvalue> to the <argumentlink>
<function>SetBulkMail</function>
<argument>on</argument>
</argumentlink> argument.</usage>
</documentation>
{/metadocument}
*/
class smtp_message_class extends email_message_class
{
/* Private variables */
var $smtp;
var $line_break="\r\n";
var $delivery = 0;
/* Public variables */
/* Allow Self Signed Certificate */
var $smtp_certificate = 0; // @flydev: https://processwire.com/talk/topic/5704-wiremailsmtp/page-5#entry113290
/* @horst: Allow Connections without Authentication */
var $allow_without_authentication = 0;
/* @horst: Allow to define the crypto method for TLS connections */
var $smtp_tls_crypto_method = '';
/* @horst: Allow to define the crypto method for SSL connections */
var $smtp_ssl_crypto_method = '';
/*
{metadocument}
<variable>
<name>localhost</name>
<value></value>
<documentation>
<purpose>Specify the domain name of the computer sending the
message.</purpose>
<usage>This value is used to identify the sending machine to the
SMTP server. When using the direct delivery mode, if this variable
is set to a non-empty string it used to generate the
<tt>Recieved</tt> header to show that the message passed by the
specified host address. To prevent confusing directly delivered
messages with spam, it is strongly recommended that you set this
variable to you server host name.</usage>
</documentation>
</variable>
{/metadocument}
*/
var $localhost="";
/*
{metadocument}
<variable>
<name>smtp_host</name>
<type>STRING</type>
<value></value>
<documentation>
<purpose>Specify the address of the SMTP server.</purpose>
<usage>Set to the address of the SMTP server that will relay the
messages. This variable is not used in direct delivery mode.</usage>
</documentation>
</variable>
{/metadocument}
*/
var $smtp_host="localhost";
/*
{metadocument}
<variable>
<name>smtp_port</name>
<type>INTEGER</type>
<value>25</value>
<documentation>
<purpose>Specify the TCP/IP port of SMTP server to connect.</purpose>
<usage>Most servers work on port 25 . Certain e-mail services use
alternative ports to avoid firewall blocking. Gmail uses port
<integervalue>465</integervalue>.</usage>
</documentation>
</variable>
{/metadocument}
*/
var $smtp_port=25;
/*
{metadocument}
<variable>
<name>smtp_ssl</name>
<type>BOOLEAN</type>
<value>0</value>
<documentation>
<purpose>Specify whether it should use secure connections with SSL
to connect to the SMTP server.</purpose>
<usage>Certain e-mail services like Gmail require SSL connections.</usage>
</documentation>
</variable>
{/metadocument}
*/
var $smtp_ssl=0;
/*
{metadocument}
<variable>
<name>smtp_start_tls</name>
<type>BOOLEAN</type>
<value>0</value>
<documentation>
<purpose>Specify whether it should use secure connections starting
TLS protocol after connecting to the SMTP server.</purpose>
<usage>Certain e-mail services like Hotmail require starting TLS
protocol after the connection to the SMTP server is already
established.</usage>
</documentation>
</variable>
{/metadocument}
*/
var $smtp_start_tls=0;
/*
{metadocument}
<variable>
<name>smtp_http_proxy_host_name</name>
<type>STRING</type>
<value></value>
<documentation>
<purpose>Specify name of the host when the connection should be
routed via an HTTP proxy.</purpose>
<usage>Leave empty if no proxy should be used.</usage>
</documentation>
</variable>
{/metadocument}
*/
var $smtp_http_proxy_host_name='';
/*
{metadocument}
<variable>
<name>smtp_http_proxy_host_port</name>
<type>INTEGER</type>
<value>3128</value>
<documentation>
<purpose>Specify proxy port when the connection should be routed via
an HTTP proxy.</purpose>
<usage>Change this variable if you need to use a proxy with a
specific port.</usage>
</documentation>
</variable>
{/metadocument}
*/
var $smtp_http_proxy_host_port=3128;
/*
{metadocument}
<variable>
<name>smtp_socks_host_name</name>
<type>STRING</type>
<value></value>
<documentation>
<purpose>Specify name of the host when the connection should be
routed via a SOCKS protocol proxy.</purpose>
<usage>Leave empty if no proxy should be used.</usage>
</documentation>
</variable>
{/metadocument}
*/
var $smtp_socks_host_name = '';
/*
{metadocument}
<variable>
<name>smtp_socks_host_port</name>
<type>INTEGER</type>
<value>1080</value>
<documentation>
<purpose>Specify proxy port when the connection should be routed via
a SOCKS protocol proxy.</purpose>
<usage>Change this variable if you need to use a proxy with a
specific port.</usage>
</documentation>
</variable>
{/metadocument}
*/
var $smtp_socks_host_port = 1080;
/*
{metadocument}
<variable>
<name>smtp_socks_version</name>
<type>STRING</type>
<value></value>
<documentation>
<purpose>Specify protocol version when the connection should be
routed via a SOCKS protocol proxy.</purpose>
<usage>Change this variable if you need to use a proxy with a
specific SOCKS protocol version.</usage>
</documentation>
</variable>
{/metadocument}
*/
var $smtp_socks_version = '5';
/*
{metadocument}
<variable>
<name>smtp_direct_delivery</name>
<type>BOOLEAN</type>
<value>0</value>
<documentation>
<purpose>Boolean flag that indicates whether the message should be
sent in direct delivery mode.</purpose>
<usage>Set this to <tt><booleanvalue>1</booleanvalue></tt> if you
want to send urgent messages directly to the recipient domain SMTP
server.</usage>
</documentation>
</variable>
{/metadocument}
*/
var $smtp_direct_delivery=0;
/*
{metadocument}
<variable>
<name>smtp_getmxrr</name>
<type>STRING</type>
<value>getmxrr</value>
<documentation>
<purpose>Specify the name of the function that is called to determine
the SMTP server address of a given domain.</purpose>
<usage>Change this to a working replacement of the PHP
<tt>getmxrr()</tt> function if this is not working in your system
and you want to send messages in direct delivery mode.</usage>
</documentation>
</variable>
{/metadocument}
*/
var $smtp_getmxrr="getmxrr";
/*
{metadocument}
<variable>
<name>smtp_exclude_address</name>
<type>STRING</type>
<value></value>
<documentation>
<purpose>Specify an address that should be considered invalid
when resolving host name addresses.</purpose>
<usage>In some networks any domain name that does not exist is
resolved as a sub-domain of the default local domain. If the DNS is
configured in such way that it always resolves any sub-domain of
the default local domain to a given address, it is hard to
determine whether a given domain does not exist.<paragraphbreak />
If your network is configured this way, you may set this variable
to the address that all sub-domains of the default local domain
resolves, so the class can assume that such address is invalid.</usage>
</documentation>
</variable>
{/metadocument}
*/
var $smtp_exclude_address="";
/*
{metadocument}
<variable>
<name>smtp_user</name>
<type>STRING</type>
<value></value>
<documentation>
<purpose>Specify the user name for authentication.</purpose>
<usage>Set this variable if you need to authenticate before sending
a message.</usage>
</documentation>
</variable>
{/metadocument}
*/
var $smtp_user="";
/*
{metadocument}
<variable>
<name>smtp_realm</name>
<type>STRING</type>
<value></value>
<documentation>
<purpose>Specify the user authentication realm.</purpose>
<usage>Set this variable if you need to authenticate before sending
a message.</usage>
</documentation>
</variable>
{/metadocument}
*/
var $smtp_realm="";
/*
{metadocument}
<variable>
<name>smtp_workstation</name>
<type>STRING</type>
<value></value>
<documentation>
<purpose>Specify the user authentication workstation needed when
using the <tt>NTLM</tt> authentication (Windows or Samba).</purpose>
<usage>Set this variable if you need to authenticate before sending
a message.</usage>
</documentation>
</variable>
{/metadocument}
*/
var $smtp_workstation="";
/*
{metadocument}
<variable>
<name>smtp_authentication_mechanism</name>
<type>STRING</type>
<value></value>
<documentation>
<purpose>Specify the user authentication mechanism that should be
used when authenticating with the SMTP server.</purpose>
<usage>Set this variable if you need to force the SMTP connection to
authenticate with a specific authentication mechanism. Leave this
variable with an empty string if you want the authentication
mechanism be determined automatically from the list of mechanisms
supported by the server.</usage>
</documentation>
</variable>
{/metadocument}
*/
var $smtp_authentication_mechanism="";
/*
{metadocument}
<variable>
<name>smtp_password</name>
<type>STRING</type>
<value></value>
<documentation>
<purpose>Specify the user authentication password.</purpose>
<usage>Set this variable if you need to authenticate before sending
a message.</usage>
</documentation>
</variable>
{/metadocument}
*/
var $smtp_password="";
/*
{metadocument}
<variable>
<name>smtp_pop3_auth_host</name>
<type>STRING</type>
<value></value>
<documentation>
<purpose>Specify the server address for POP3 based authentication.</purpose>
<usage>Set this variable to the address of the POP3 server if the
SMTP server requires POP3 based authentication.</usage>
</documentation>
</variable>
{/metadocument}
*/
var $smtp_pop3_auth_host="";
/*
{metadocument}
<variable>
<name>smtp_debug</name>
<type>BOOLEAN</type>
<value>0</value>
<documentation>
<purpose>Specify whether it is necessary to output SMTP connection
debug information.</purpose>
<usage>Set this variable to
<tt><booleanvalue>1</booleanvalue></tt> if you need to see
the progress of the SMTP connection and protocol dialog when you
need to understand the reason for delivery problems.</usage>
</documentation>
</variable>
{/metadocument}
*/
var $smtp_debug=0;
/*
{metadocument}
<variable>
<name>smtp_html_debug</name>
<type>BOOLEAN</type>
<value>0</value>
<documentation>
<purpose>Specify whether the debug information should be outputted in
HTML format.</purpose>
<usage>Set this variable to
<tt><booleanvalue>1</booleanvalue></tt> if you need to see
the debug output in a Web page.</usage>
</documentation>
</variable>
{/metadocument}
*/
var $smtp_html_debug=0;
/*
{metadocument}
<variable>
<name>esmtp</name>
<type>BOOLEAN</type>
<value>1</value>
<documentation>
<purpose>Specify whether the class should try to use Enhanced SMTP
protocol features.</purpose>
<usage>It is recommended to leave this variable set to
<tt><booleanvalue>1</booleanvalue></tt> so the class can take
advantage of Enhanced SMTP protocol features.</usage>
</documentation>
</variable>
{/metadocument}
*/
var $esmtp=1;
/*
{metadocument}
<variable>
<name>timeout</name>
<type>INTEGER</type>
<value>25</value>
<documentation>
<purpose>Specify the connection timeout period in seconds.</purpose>
<usage>Change this value if for some reason the timeout period seems
insufficient or otherwise it seems too long.</usage>
</documentation>
</variable>
{/metadocument}
*/
var $timeout=25;
/*
{metadocument}
<variable>
<name>invalid_recipients</name>
<type>ARRAY</type>
<value></value>
<documentation>
<purpose>Return the list of recipient addresses that were not
accepted by the SMTP server.</purpose>
<usage>Check this variable after attempting to send a message to
figure whether there were any recipients that were rejected by the
SMTP server.</usage>
</documentation>
</variable>
{/metadocument}
*/
var $invalid_recipients=array();
/*
{metadocument}
<variable>
<name>mailer_delivery</name>
<value>smtp $Revision: 1.36 $</value>
<documentation>
<purpose>Specify the text that is used to identify the mail
delivery class or sub-class. This text is appended to the
<tt>X-Mailer</tt> header text defined by the
mailer variable.</purpose>
<usage>Do not change this variable.</usage>
</documentation>
</variable>
{/metadocument}
*/
var $mailer_delivery='smtp $Revision: 1.36 $';
/*
{metadocument}
<variable>
<name>maximum_bulk_deliveries</name>
<type>INTEGER</type>
<value>100</value>
<documentation>
<purpose>Specify the number of consecutive bulk mail deliveries
without disconnecting.</purpose>
<usage>Lower this value if you have enabled the bulk mail mode but
the SMTP server does not accept sending more than a number of
messages within the same SMTP connection.<paragraphbreak />
Set this value to <integervalue>0</integervalue> to never
disconnect during bulk mail mode unless an error occurs.</usage>
</documentation>
</variable>
{/metadocument}
*/
var $maximum_bulk_deliveries=100;
Function SetRecipients(&$recipients,&$valid_recipients)
{
for($valid_recipients=$recipient=0,Reset($recipients);$recipient<count($recipients);Next($recipients),$recipient++)
{
$address=Key($recipients);
if($this->smtp->SetRecipient($address))
$valid_recipients++;
else
$this->invalid_recipients[$address]=$this->smtp->error;
}
return(1);
}
Function ResetConnection($error)
{
if(IsSet($this->smtp))
{
if(!$this->smtp->Disconnect()
&& strlen($error) == 0)
$error = $this->smtp->error;
UnSet($this->smtp);
}
if(strlen($error))
$this->OutputError($error);
return($error);
}
Function StartSendingMessage()
{
if(function_exists("class_exists")
&& !class_exists("smtp_class"))
return("the smtp_class class was not included");
if(IsSet($this->smtp))
return("");
$this->smtp=new smtp_class;
$this->smtp->localhost=$this->localhost;
$this->smtp->host_name=$this->smtp_host;
$this->smtp->host_port=$this->smtp_port;
$this->smtp->ssl=$this->smtp_ssl;
$this->smtp->smtp_ssl_crypto_method=$this->smtp_ssl_crypto_method; // @horst
$this->smtp->start_tls=$this->smtp_start_tls;
$this->smtp->smtp_tls_crypto_method=$this->smtp_tls_crypto_method; // @horst
$this->smtp->http_proxy_host_name=$this->smtp_http_proxy_host_name;
$this->smtp->http_proxy_host_port=$this->smtp_http_proxy_host_port;
$this->smtp->socks_host_name=$this->smtp_socks_host_name;
$this->smtp->socks_host_port=$this->smtp_socks_host_port;
$this->smtp->socks_version=$this->smtp_socks_version;
$this->smtp->timeout=$this->timeout;
$this->smtp->debug=$this->smtp_debug;
$this->smtp->html_debug=$this->smtp_html_debug;
$this->smtp->direct_delivery=$this->smtp_direct_delivery;
$this->smtp->getmxrr=$this->smtp_getmxrr;
$this->smtp->exclude_address=$this->smtp_exclude_address;
$this->smtp->pop3_auth_host=$this->smtp_pop3_auth_host;
$this->smtp->user=$this->smtp_user;
$this->smtp->realm=$this->smtp_realm;
$this->smtp->workstation=$this->smtp_workstation;
$this->smtp->authentication_mechanism=$this->smtp_authentication_mechanism;
$this->smtp->password=$this->smtp_password;
$this->smtp->esmtp=$this->esmtp;
$this->smtp->smtp_certificate = $this->smtp_certificate; // @flydev: https://processwire.com/talk/topic/5704-wiremailsmtp/page-5#entry113290
$this->smtp->allow_without_authentication = $this->allow_without_authentication; // @horst
if($this->smtp->Connect())
{
$this->delivery = 0;
return("");
}
return($this->ResetConnection($this->smtp->error));
}
Function SendMessageHeaders($headers)
{
$header_data="";
$date=date("D, d M Y H:i:s T");
if($this->smtp_direct_delivery
&& strlen($this->localhost))
{
$local_ip=gethostbyname($this->localhost);
$header_data.=$this->FormatHeader("Received","FROM ".$this->localhost." ([".$local_ip."]) BY ".$this->localhost." ([".$local_ip."]) WITH SMTP; ".$date)."\r\n";
}
for($message_id_set=$date_set=0,$header=0,$return_path=$from=$to=$recipients=array(),Reset($headers);$header<count($headers);$header++,Next($headers))
{
$header_name=Key($headers);
switch(strtolower($header_name))
{
case "return-path":
$return_path[$headers[$header_name]]=1;
break;
case "from":
$error=$this->GetRFC822Addresses($headers[$header_name],$from);
break;
case "to":
$error=$this->GetRFC822Addresses($headers[$header_name],$to);
break;
case "cc":
case "bcc":
$this->GetRFC822Addresses($headers[$header_name],$recipients);
break;
case "date":
$date_set=1;
break;
case "message-id":
$message_id_set=1;
break;
}
if(strcmp($error,""))
return($this->ResetConnection($error));
if(strtolower($header_name)=="bcc")
continue;
$header_data.=$this->FormatHeader($header_name,$headers[$header_name])."\r\n";
}
if(count($from)==0)
return($this->ResetConnection("it was not specified a valid From header"));
Reset($return_path);
Reset($from);
$this->invalid_recipients=array();
if(!$this->smtp->MailFrom(count($return_path) ? Key($return_path) : Key($from)))
return($this->ResetConnection($this->smtp->error));
$r = 0;
if(count($to))
{
if(!$this->SetRecipients($to,$valid_recipients))
return($this->ResetConnection($this->smtp->error));
$r += $valid_recipients;
}
if(!$date_set)
$header_data.="Date: ".$date."\r\n";
if(!$message_id_set
&& $this->auto_message_id)
{
$sender=(count($return_path) ? Key($return_path) : Key($from));
$header_data.=$this->GenerateMessageID($sender)."\r\n";
}
if(count($recipients))
{
if(!$this->SetRecipients($recipients,$valid_recipients))
return($this->ResetConnection($this->smtp->error));
$r += $valid_recipients;
}
if($r==0)
return($this->ResetConnection("it were not specified any valid recipients"));
if(!$this->smtp->StartData()
|| !$this->smtp->SendData($header_data."\r\n"))
return($this->ResetConnection($this->smtp->error));
return("");
}
Function SendMessageBody($data)
{
return($this->smtp->SendData($this->smtp->PrepareData($data)) ? "" : $this->ResetConnection($this->smtp->error));
}
Function EndSendingMessage()
{
return($this->smtp->EndSendingData() ? "" : $this->ResetConnection($this->smtp->error));
}
Function StopSendingMessage()
{
++$this->delivery;
if($this->bulk_mail
&& !$this->smtp_direct_delivery
&& ($this->maximum_bulk_deliveries == 0
|| $this->delivery < $this->maximum_bulk_deliveries))
return("");
return($this->ResetConnection(''));
}
Function ChangeBulkMail($on)
{
if($on
|| !IsSet($this->smtp))
return(1);
return($this->smtp->Disconnect() ? "" : $this->ResetConnection($this->smtp->error));
}
};
/*
{metadocument}
</class>
{/metadocument}
*/
?>

View file

@ -90,8 +90,8 @@ $contido .= '</div>' . "\n";
$contido .= '</div>' . "\n"; $contido .= '</div>' . "\n";
$contido .= '</div>' . "\n"; $contido .= '</div>' . "\n";
$contido .= '</div>' . "\n"; $contido .= '</div>' . "\n";
$contido .= '<div class="row py-5">' . "\n"; $contido .= '<div class="row row-cols-1 row-cols-sm-2 row-cols-lg-3 py-5 justify-content-center">' . "\n";
$contido .= '<div class="feature col-md-6 col-lg-3 text-center">' . "\n"; $contido .= '<div class="feature col text-center">' . "\n";
$contido .= '<div class="feature-icon d-inline-flex align-items-center justify-content-center text-bg-primary bg-gradient fs-2 mb-3">' . "\n"; $contido .= '<div class="feature-icon d-inline-flex align-items-center justify-content-center text-bg-primary bg-gradient fs-2 mb-3">' . "\n";
$contido .= '<i class="icon-map-pin"></i>' . "\n"; $contido .= '<i class="icon-map-pin"></i>' . "\n";
$contido .= '</div>' . "\n"; $contido .= '</div>' . "\n";
@ -100,7 +100,7 @@ $contido .= '<p class="fs-4">' . _x('Address', 'address') . ':</p>' . "\n";
$contido .= '<p>' . $configuracion['contacto_direccion'] . '</p>' . "\n"; $contido .= '<p>' . $configuracion['contacto_direccion'] . '</p>' . "\n";
$contido .= '</div>' . "\n"; $contido .= '</div>' . "\n";
$contido .= '</div>' . "\n"; $contido .= '</div>' . "\n";
$contido .= '<div class="feature col-md-6 col-lg-3 text-center">' . "\n"; $contido .= '<div class="feature col text-center">' . "\n";
$contido .= '<div class="feature-icon d-inline-flex align-items-center justify-content-center text-bg-primary bg-gradient fs-2 mb-3">' . "\n"; $contido .= '<div class="feature-icon d-inline-flex align-items-center justify-content-center text-bg-primary bg-gradient fs-2 mb-3">' . "\n";
$contido .= '<i class="icon-phone"></i>' . "\n"; $contido .= '<i class="icon-phone"></i>' . "\n";
$contido .= '</div>' . "\n"; $contido .= '</div>' . "\n";
@ -109,7 +109,7 @@ $contido .= '<p class="fs-4">' . _x('Teléfono', 'phone') . '</p>' . "\n";
$contido .= '<p><a href="tel://' . $configuracion['contacto_telefono'] . '">' . $configuracion['contacto_telefono'] . '</a></p>' . "\n"; $contido .= '<p><a href="tel://' . $configuracion['contacto_telefono'] . '">' . $configuracion['contacto_telefono'] . '</a></p>' . "\n";
$contido .= '</div>' . "\n"; $contido .= '</div>' . "\n";
$contido .= '</div>' . "\n"; $contido .= '</div>' . "\n";
$contido .= '<div class="feature col-md-6 col-lg-3 text-center">' . "\n"; $contido .= '<div class="feature col text-center">' . "\n";
$contido .= '<div class="feature-icon d-inline-flex align-items-center justify-content-center text-bg-primary bg-gradient fs-2 mb-3">' . "\n"; $contido .= '<div class="feature-icon d-inline-flex align-items-center justify-content-center text-bg-primary bg-gradient fs-2 mb-3">' . "\n";
$contido .= '<i class="icon-mail"></i>' . "\n"; $contido .= '<i class="icon-mail"></i>' . "\n";
$contido .= '</div>' . "\n"; $contido .= '</div>' . "\n";
@ -118,14 +118,5 @@ $contido .= '<p class="fs-4">' . _x('Correo electrónico', 'email') . ':</p>' .
$contido .= '<p><a href="mailto:' . $configuracion['contacto_correo'] . '">' . $configuracion['contacto_correo'] . '</a></p>' . "\n"; $contido .= '<p><a href="mailto:' . $configuracion['contacto_correo'] . '">' . $configuracion['contacto_correo'] . '</a></p>' . "\n";
$contido .= '</div>' . "\n"; $contido .= '</div>' . "\n";
$contido .= '</div>' . "\n"; $contido .= '</div>' . "\n";
$contido .= '<div class="feature col-md-6 col-lg-3 text-center">' . "\n";
$contido .= '<div class="feature-icon d-inline-flex align-items-center justify-content-center text-bg-primary bg-gradient fs-2 mb-3">' . "\n";
$contido .= '<i class="icon-clock"></i>' . "\n";
$contido .= '</div>' . "\n";
$contido .= '<div class="text">' . "\n";
$contido .= '<p class="fs-4">' . _x('Horario', 'schedule') . ':</p>' . "\n";
$contido .= '<p>' . _x('luns a venres', 'monday to friday') . ' ' . $configuracion['horario_apertura'] . ' - ' . $configuracion['horario_peche'] . '</p>' . "\n";
$contido .= '</div>' . "\n";
$contido .= '</div>' . "\n";
$contido .= '</div>' . "\n"; $contido .= '</div>' . "\n";
$contido .= '</article>' . "\n"; $contido .= '</article>' . "\n";

View file

@ -2,7 +2,7 @@
* @FONTS * @FONTS
* ============================================================================= * =============================================================================
* *
* fonts.css v0.1.17 | GNU GPL License | * fonts.css v0.1.20 | GNU GPL License |
* *
*/ */
@ -132,13 +132,13 @@
@font-face @font-face
{ {
font-family: 'icomoon'; font-family: 'icomoon';
src: url('../fonts/icomoon_Regular.eot?q4r8w8'); /* 1 */ src: url('../fonts/icomoon_Regular.eot?qri1u5'); /* 1 */
src: url('../fonts/icomoon_Regular.eot?q4r8w8#iefix') format('embedded-opentype'), /* 2 */ src: url('../fonts/icomoon_Regular.eot?qri1u5#iefix') format('embedded-opentype'), /* 2 */
url('../fonts/icomoon_Regular.woff2?q4r8w8') format('woff2'), /* 3 */ url('../fonts/icomoon_Regular.woff2?qri1u5') format('woff2'), /* 3 */
url('../fonts/icomoon_Regular.woff?q4r8w8') format('woff'), /* 4 */ url('../fonts/icomoon_Regular.woff?qri1u5') format('woff'), /* 4 */
url('../fonts/icomoon_Regular.otf?q4r8w8') format('opentype'), /* 5 */ url('../fonts/icomoon_Regular.otf?qri1u5') format('opentype'), /* 5 */
url('../fonts/icomoon_Regular.ttf?q4r8w8') format('truetype'), /* 5 */ url('../fonts/icomoon_Regular.ttf?qri1u5') format('truetype'), /* 5 */
url('../fonts/icomoon_Regular.svg?q4r8w8#icomoon') format('svg'); /* 6 */ url('../fonts/icomoon_Regular.svg?qri1u5#icomoon') format('svg'); /* 6 */
font-display: block; font-display: block;
font-style: normal; font-style: normal;
font-weight: normal; font-weight: normal;
@ -281,6 +281,21 @@
content: "\e917"; content: "\e917";
} }
.icon-map-pin:before
{
content: "\e918";
}
.icon-phone:before
{
content: "\e919";
}
.icon-mail:before
{
content: "\e91a";
}
.icon-tv:before .icon-tv:before
{ {
content: "\ebce"; content: "\ebce";

View file

@ -2,7 +2,7 @@
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd" > <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd" >
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1"> <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1">
<metadata> <metadata>
Created by FontForge 20201107 at Tue Feb 21 10:59:28 2023 Created by FontForge 20201107 at Fri Mar 10 18:08:55 2023
By Unknown By Unknown
</metadata> </metadata>
<defs> <defs>
@ -127,6 +127,21 @@ d="M1023 360l-212 221v251q0 9 -6.5 15t-15.5 6h-128q-8 0 -14.5 -6t-6.5 -15v-74l-6
t15.5 -6.5h149q35 0 60 25t25 60v328l108 -112l62 59v0zM683 811h85v-186l-85 89v97v0zM768 85h-128v235q0 9 -6.5 15t-14.5 6h-214q-8 0 -14.5 -6t-6.5 -15v-235h-128v417l256 266l256 -266v-417v0z" /> t15.5 -6.5h149q35 0 60 25t25 60v328l108 -112l62 59v0zM683 811h85v-186l-85 89v97v0zM768 85h-128v235q0 9 -6.5 15t-14.5 6h-214q-8 0 -14.5 -6t-6.5 -15v-235h-128v417l256 266l256 -266v-417v0z" />
<glyph glyph-name="uniE917" unicode="&#xe917;" <glyph glyph-name="uniE917" unicode="&#xe917;"
d="M226 525l256 -256q12 -13 30 -13t30 13l256 256q13 12 13 29.5t-13 30.5q-12 12 -30 12t-30 -12l-226 -226l-226 226q-12 12 -30 12t-30 -12q-13 -13 -13 -30.5t13 -29.5v0z" /> d="M226 525l256 -256q12 -13 30 -13t30 13l256 256q13 12 13 29.5t-13 30.5q-12 12 -30 12t-30 -12l-226 -226l-226 226q-12 12 -30 12t-30 -12q-13 -13 -13 -30.5t13 -29.5v0z" />
<glyph glyph-name="uniE918" unicode="&#xe918;"
d="M939 512q0 44 -9 86t-25 80t-39 73q-23 34 -52 63t-63 52q-35 23 -73 39t-80 25t-86 9t-86 -9t-80 -25t-73 -39q-34 -23 -63 -52t-52 -63q-23 -35 -39 -73t-25 -80t-9 -86q0 -18 2 -36t5 -36q9 -49 27.5 -95.5t43.5 -88.5q44 -73 100 -135q57 -61 107 -105.5t84 -68.5
l34 -25q11 -7 24 -7t24 7l34 25q34 24 84 68.5t107 105.5q56 62 99 135q26 42 44.5 88.5t27.5 95.5q3 18 5 36t2 36v0zM853 512q0 -14 -1 -28.5t-4 -28.5q-7 -40 -23 -79t-38 -76q-30 -52 -69 -97q-38 -45 -76 -82.5t-72 -64.5q-33 -28 -55 -44q-22 15 -57 42
q-34 27 -73 64.5t-78 83.5t-70 98q-22 37 -38 76t-23 79q-3 14 -4 28.5t-1 28.5q0 71 26.5 133t73.5 108q46 47 108 73.5t133 26.5t133 -26.5t108 -73.5q47 -46 73.5 -108t26.5 -133v0zM683 512q0 35 -13.5 66.5t-36.5 54.5t-54.5 36.5t-66.5 13.5t-66.5 -13.5t-54.5 -36.5
t-36.5 -54.5t-13.5 -66.5t13.5 -66.5t36.5 -54.5t54.5 -36.5t66.5 -13.5t66.5 13.5t54.5 36.5t36.5 54.5t13.5 66.5zM597 512q0 -18 -6.5 -33.5t-18.5 -26.5q-11 -12 -26.5 -18.5t-33.5 -6.5t-33.5 6.5t-26.5 18.5q-12 11 -18.5 26.5t-6.5 33.5t6.5 33.5t18.5 26.5
q11 12 26.5 18.5t33.5 6.5t33.5 -6.5t26.5 -18.5q12 -11 18.5 -26.5t6.5 -33.5z" />
<glyph glyph-name="uniE919" unicode="&#xe919;"
d="M981 217q1 23 -6.5 44t-21.5 39q-15 18 -36 30t-47 16q-25 3 -53 10t-57 17q-14 5 -28.5 7t-28.5 1q-21 -2 -41 -11.5t-37 -25.5l-31 -30q-56 35 -106 84.5t-89 110.5l31 31q10 11 17.5 23.5t12.5 26.5q7 20 7 42t-9 43q-9 25 -16 53t-11 58q-3 23 -14 42.5t-27 34.5
q-17 16 -39.5 24.5t-47.5 8.5h-127h-6t-6 -1q-26 -2 -48.5 -14t-38.5 -31t-23.5 -43t-5.5 -51q5 -49 16 -99q11 -49 28 -98.5t40 -96.5q24 -48 53 -94q24 -39 53 -76q29 -36 63 -70t72 -65q39 -31 81 -58q41 -27 86 -50q46 -23 94.5 -40.5t100.5 -29.5t107 -18q3 0 6 -0.5
t6 -0.5q26 0 49.5 10.5t40.5 27.5q18 18 27.5 41t9.5 50v128zM896 217v-128q0 -9 -3.5 -17t-8.5 -14q-6 -5 -14 -8.5t-16 -3.5q-51 5 -98 16q-48 11 -92.5 27t-84.5 36q-41 21 -78 45q-39 25 -74 53t-65.5 58.5t-56.5 63.5t-47 68q-27 42 -49 85q-21 44 -36.5 88.5
t-25.5 89.5q-10 44 -14 88q-1 9 1.5 17t8.5 14q5 7 12.5 11t16.5 4l131 1q9 0 16.5 -3t13.5 -8q5 -5 8.5 -11.5t4.5 -14.5q5 -35 13.5 -67.5t19.5 -61.5q2 -7 2 -14.5t-2 -13.5q-1 -5 -4 -9.5t-6 -7.5l-54 -54q-10 -10 -12 -24.5t5 -26.5q25 -45 56 -84q30 -40 64.5 -74
t73.5 -63q38 -29 78 -51q13 -7 27 -5t24 12l55 54q5 5 11.5 8t13.5 4q5 0 10 -0.5t10 -2.5q32 -12 65 -20t64 -12q8 -1 14.5 -5t11.5 -10t7.5 -13.5t2.5 -15.5v0z" />
<glyph glyph-name="uniE91A" unicode="&#xe91a;"
d="M128 601l360 -252q10 -8 23.5 -8t24.5 8l360 252v-430q0 -9 -3.5 -17t-9.5 -13q-6 -6 -13.5 -9.5t-16.5 -3.5h-682q-9 0 -17 3.5t-13 9.5q-6 6 -9.5 13.5t-3.5 16.5v430zM43 683v-0.5v-0.5v-511q0 -27 10 -50t27 -41q17 -17 40.5 -27t50.5 -10h682q27 0 50 10t41 27
q17 17 27 40.5t10 50.5v511v0.5v0.5q0 27 -10 50t-27 40q-18 17 -41 27.5t-50 10.5h-682q-27 0 -50 -10.5t-41 -27.5q-17 -17 -27 -40t-10 -50v0zM891 702l-379 -266l-379 266q1 3 3 5.5t5 5.5q5 6 13 9t17 3h682q9 0 17 -3t13 -9q3 -3 5 -5.5t3 -5.5v0z" />
<glyph glyph-name="uniEAA1" unicode="&#xeaa1;" <glyph glyph-name="uniEAA1" unicode="&#xeaa1;"
d="M939 939h-854q-35 0 -60 -25t-25 -61v-853q0 -35 25 -60t60 -25h854q35 0 60 25t25 60v853q0 36 -25 61t-60 25v0zM939 0h-854v853v0v0h854v-853zM149 43h726q8 0 14.5 6t6.5 15v725q0 9 -6.5 15.5t-14.5 6.5h-726q-8 0 -14.5 -6.5t-6.5 -15.5v-725q0 -9 6.5 -15t14.5 -6 d="M939 939h-854q-35 0 -60 -25t-25 -61v-853q0 -35 25 -60t60 -25h854q35 0 60 25t25 60v853q0 36 -25 61t-60 25v0zM939 0h-854v853v0v0h854v-853zM149 43h726q8 0 14.5 6t6.5 15v725q0 9 -6.5 15.5t-14.5 6.5h-726q-8 0 -14.5 -6.5t-6.5 -15.5v-725q0 -9 6.5 -15t14.5 -6
v0zM327 85l317 317q12 12 27.5 18.5t32.5 6.5t32.5 -6.5t27.5 -18.5l89 -89v-228h-526v0zM853 768v-395l-58 59q-19 18 -42 27.5t-49 9.5t-49 -9.5t-42 -27.5l-346 -347h-96v103l140 141q13 12 30.5 12t30.5 -12l39 -39l30 30l-39 39q-25 25 -60.5 25t-60.5 -25l-110 -110 v0zM327 85l317 317q12 12 27.5 18.5t32.5 6.5t32.5 -6.5t27.5 -18.5l89 -89v-228h-526v0zM853 768v-395l-58 59q-19 18 -42 27.5t-49 9.5t-49 -9.5t-42 -27.5l-346 -347h-96v103l140 141q13 12 30.5 12t30.5 -12l39 -39l30 30l-39 39q-25 25 -60.5 25t-60.5 -25l-110 -110

Before

Width:  |  Height:  |  Size: 34 KiB

After

Width:  |  Height:  |  Size: 37 KiB

View file

@ -257,7 +257,7 @@ function renderGaleria($seccion)
{ {
$saida = ''; $saida = '';
$saida .= '<section id="galeria" class="galeria contedor columna swiper d-none d-md-block">' . "\n"; $saida .= '<section id="galeria" class="swiper d-none d-md-block">' . "\n";
$saida .= '<h3 class="visually-hidden">' . (($seccion->titular) ? $seccion->titular : 'Galeria') . '</h3>' . "\n"; $saida .= '<h3 class="visually-hidden">' . (($seccion->titular) ? $seccion->titular : 'Galeria') . '</h3>' . "\n";
$saida .= '<div class="swiper-wrapper">' . "\n"; $saida .= '<div class="swiper-wrapper">' . "\n";
foreach($seccion->imaxes as $imaxe) foreach($seccion->imaxes as $imaxe)