ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
PHPMailerOAuth Class Reference
+ Inheritance diagram for PHPMailerOAuth:
+ Collaboration diagram for PHPMailerOAuth:

Public Member Functions

 getOAUTHInstance ()
 Get a PHPMailerOAuthGoogle instance to use. More...
 
 smtpConnect ($options=array())
 Initiate a connection to an SMTP server. More...
 
- Public Member Functions inherited from PHPMailer
 __construct ($exceptions=null)
 Constructor. More...
 
 __destruct ()
 Destructor. More...
 
 isHTML ($isHtml=true)
 Sets message type to HTML or plain. More...
 
 isSMTP ()
 Send messages using SMTP. More...
 
 isMail ()
 Send messages using PHP's mail() function. More...
 
 isSendmail ()
 Send messages using $Sendmail. More...
 
 isQmail ()
 Send messages using qmail. More...
 
 addAddress ($address, $name='')
 Add a "To" address. More...
 
 addCC ($address, $name='')
 Add a "CC" address. More...
 
 addBCC ($address, $name='')
 Add a "BCC" address. More...
 
 addReplyTo ($address, $name='')
 Add a "Reply-To" address. More...
 
 parseAddresses ($addrstr, $useimap=true)
 Parse and validate a string containing one or more RFC822-style comma-separated email addresses of the form "display name <address>" into an array of name/address pairs. More...
 
 setFrom ($address, $name='', $auto=true)
 Set the From and FromName properties. More...
 
 getLastMessageID ()
 Return the Message-ID header of the last email. More...
 
 idnSupported ()
 Tells whether IDNs (Internationalized Domain Names) are supported or not. More...
 
 punyencodeAddress ($address)
 Converts IDN in given email address to its ASCII form, also known as punycode, if possible. More...
 
 send ()
 Create a message and send it. More...
 
 preSend ()
 Prepare a message for sending. More...
 
 postSend ()
 Actually send a message. More...
 
 getSMTPInstance ()
 Get an instance to use for SMTP operations. More...
 
 smtpConnect ($options=null)
 Initiate a connection to an SMTP server. More...
 
 smtpClose ()
 Close the active SMTP session if one exists. More...
 
 setLanguage ($langcode='en', $lang_path='')
 Set the language for error messages. More...
 
 getTranslations ()
 Get the array of strings for the current language. More...
 
 addrAppend ($type, $addr)
 Create recipient headers. More...
 
 addrFormat ($addr)
 Format an address for use in a message header. More...
 
 wrapText ($message, $length, $qp_mode=false)
 Word-wrap message. More...
 
 utf8CharBoundary ($encodedText, $maxLength)
 Find the last character boundary prior to $maxLength in a utf-8 quoted-printable encoded string. More...
 
 setWordWrap ()
 Apply word wrapping to the message body. More...
 
 createHeader ()
 Assemble message headers. More...
 
 getMailMIME ()
 Get the message MIME type headers. More...
 
 getSentMIMEMessage ()
 Returns the whole MIME message. More...
 
 createBody ()
 Assemble the message body. More...
 
 headerLine ($name, $value)
 Format a header line. More...
 
 textLine ($value)
 Return a formatted mail line. More...
 
 addAttachment ($path, $name='', $encoding='base64', $type='', $disposition='attachment')
 Add an attachment from a path on the filesystem. More...
 
 getAttachments ()
 Return the array of attachments. More...
 
 encodeString ($str, $encoding='base64')
 Encode a string in requested format. More...
 
 encodeHeader ($str, $position='text')
 Encode a header string optimally. More...
 
 hasMultiBytes ($str)
 Check if a string contains multi-byte characters. More...
 
 has8bitChars ($text)
 Does a string contain any 8-bit chars (in any charset)? More...
 
 base64EncodeWrapMB ($str, $linebreak=null)
 Encode and wrap long multibyte strings for mail headers without breaking lines within a character. More...
 
 encodeQP ($string, $line_max=76)
 Encode a string in quoted-printable format. More...
 
 encodeQPphp ( $string, $line_max=76, $space_conv=false)
 Backward compatibility wrapper for an old QP encoding function that was removed. More...
 
 encodeQ ($str, $position='text')
 Encode a string using Q encoding. More...
 
 addStringAttachment ( $string, $filename, $encoding='base64', $type='', $disposition='attachment')
 Add a string or binary attachment (non-filesystem). More...
 
 addEmbeddedImage ($path, $cid, $name='', $encoding='base64', $type='', $disposition='inline')
 Add an embedded (inline) attachment from a file. More...
 
 addStringEmbeddedImage ( $string, $cid, $name='', $encoding='base64', $type='', $disposition='inline')
 Add an embedded stringified attachment. More...
 
 inlineImageExists ()
 Check if an inline attachment is present. More...
 
 attachmentExists ()
 Check if an attachment (non-inline) is present. More...
 
 alternativeExists ()
 Check if this message has an alternative body set. More...
 
 clearQueuedAddresses ($kind)
 Clear queued addresses of given kind. More...
 
 clearAddresses ()
 Clear all To recipients. More...
 
 clearCCs ()
 Clear all CC recipients. More...
 
 clearBCCs ()
 Clear all BCC recipients. More...
 
 clearReplyTos ()
 Clear all ReplyTo recipients. More...
 
 clearAllRecipients ()
 Clear all recipient types. More...
 
 clearAttachments ()
 Clear all filesystem, string, and binary attachments. More...
 
 clearCustomHeaders ()
 Clear all custom headers. More...
 
 isError ()
 Check if an error occurred. More...
 
 fixEOL ($str)
 Ensure consistent line endings in a string. More...
 
 addCustomHeader ($name, $value=null)
 Add a custom header. More...
 
 getCustomHeaders ()
 Returns all custom headers. More...
 
 msgHTML ($message, $basedir='', $advanced=false)
 Create a message body from an HTML string. More...
 
 html2text ($html, $advanced=false)
 Convert an HTML string into plain text. More...
 
 set ($name, $value='')
 Set or reset instance properties. More...
 
 secureHeader ($str)
 Strip newlines to prevent header injection. More...
 
 sign ($cert_filename, $key_filename, $key_pass, $extracerts_filename='')
 Set the public and private key files and password for S/MIME signing. More...
 
 DKIM_QP ($txt)
 Quoted-Printable-encode a DKIM header. More...
 
 DKIM_Sign ($signHeader)
 Generate a DKIM signature. More...
 
 DKIM_HeaderC ($signHeader)
 Generate a DKIM canonicalization header. More...
 
 DKIM_BodyC ($body)
 Generate a DKIM canonicalization body. More...
 
 DKIM_Add ($headers_line, $subject, $body)
 Create the DKIM header and body in a new message header. More...
 
 getToAddresses ()
 Allows for public read access to 'to' property. More...
 
 getCcAddresses ()
 Allows for public read access to 'cc' property. More...
 
 getBccAddresses ()
 Allows for public read access to 'bcc' property. More...
 
 getReplyToAddresses ()
 Allows for public read access to 'ReplyTo' property. More...
 
 getAllRecipientAddresses ()
 Allows for public read access to 'all_recipients' property. More...
 

Data Fields

 $oauthUserEmail = ''
 
 $oauthRefreshToken = ''
 
 $oauthClientId = ''
 
 $oauthClientSecret = ''
 
- Data Fields inherited from PHPMailer
 $Version = '5.2.24'
 
 $Priority = null
 
 $CharSet = 'iso-8859-1'
 
 $ContentType = 'text/plain'
 
 $Encoding = '8bit'
 
 $ErrorInfo = ''
 
 $From = 'root@localhost'
 
 $FromName = 'Root User'
 
 $Sender = ''
 
 $ReturnPath = ''
 
 $Subject = ''
 
 $Body = ''
 
 $AltBody = ''
 
 $Ical = ''
 
 $WordWrap = 0
 
 $Mailer = 'mail'
 
 $Sendmail = '/usr/sbin/sendmail'
 
 $UseSendmailOptions = true
 
 $PluginDir = ''
 
 $ConfirmReadingTo = ''
 
 $Hostname = ''
 
 $MessageID = ''
 
 $MessageDate = ''
 
 $Host = 'localhost'
 
 $Port = 25
 
 $Helo = ''
 
 $SMTPSecure = ''
 
 $SMTPAutoTLS = true
 
 $SMTPAuth = false
 
 $SMTPOptions = array()
 
 $Username = ''
 
 $Password = ''
 
 $AuthType = ''
 
 $Realm = ''
 
 $Workstation = ''
 
 $Timeout = 300
 
 $SMTPDebug = 0
 
 $Debugoutput = 'echo'
 
 $SMTPKeepAlive = false
 
 $SingleTo = false
 
 $SingleToArray = array()
 
 $do_verp = false
 
 $AllowEmpty = false
 
 $LE = "\n"
 
 $DKIM_selector = ''
 
 $DKIM_identity = ''
 
 $DKIM_passphrase = ''
 
 $DKIM_domain = ''
 
 $DKIM_private = ''
 
 $DKIM_private_string = ''
 
 $action_function = ''
 
 $XMailer = ''
 
const STOP_MESSAGE = 0
 Error severity: message only, continue processing. More...
 
const STOP_CONTINUE = 1
 Error severity: message, likely ok to continue processing. More...
 
const STOP_CRITICAL = 2
 Error severity: message, plus full stop, critical error reached. More...
 
const CRLF = "\r\n"
 SMTP RFC standard line ending. More...
 
const MAX_LINE_LENGTH = 998
 

Protected Attributes

 $oauth = null
 
- Protected Attributes inherited from PHPMailer
 $MIMEBody = ''
 
 $MIMEHeader = ''
 
 $mailHeader = ''
 
 $smtp = null
 
 $to = array()
 
 $cc = array()
 
 $bcc = array()
 
 $ReplyTo = array()
 
 $all_recipients = array()
 
 $RecipientsQueue = array()
 
 $ReplyToQueue = array()
 
 $attachment = array()
 
 $CustomHeader = array()
 
 $lastMessageID = ''
 
 $message_type = ''
 
 $boundary = array()
 
 $language = array()
 
 $error_count = 0
 
 $sign_cert_file = ''
 
 $sign_key_file = ''
 
 $sign_extracerts_file = ''
 
 $sign_key_pass = ''
 
 $exceptions = false
 
 $uniqueid = ''
 

Additional Inherited Members

- Static Public Member Functions inherited from PHPMailer
static validateAddress ($address, $patternselect=null)
 Check that a string looks like an email address. More...
 
static rfcDate ()
 Return an RFC 822 formatted date. More...
 
static _mime_types ($ext='')
 Get the MIME type for a file extension. More...
 
static filenameToType ($filename)
 Map a file name to a MIME type. More...
 
static mb_pathinfo ($path, $options=null)
 Multi-byte-safe pathinfo replacement. More...
 
static normalizeBreaks ($text, $breaktype="\")
 Normalize line breaks in a string. More...
 
static hasLineLongerThanMax ($str)
 Detect if a string contains a line longer than the maximum line length allowed. More...
 
- Static Public Attributes inherited from PHPMailer
static $validator = 'auto'
 
- Protected Member Functions inherited from PHPMailer
 edebug ($str)
 Output debugging info via user-defined method. More...
 
 addOrEnqueueAnAddress ($kind, $address, $name)
 Add an address to one of the recipient arrays or to the ReplyTo array. More...
 
 addAnAddress ($kind, $address, $name='')
 Add an address to one of the recipient arrays or to the ReplyTo array. More...
 
 sendmailSend ($header, $body)
 Send mail using the $Sendmail program. More...
 
 mailSend ($header, $body)
 Send mail using the PHP mail() function. More...
 
 smtpSend ($header, $body)
 Send mail via SMTP. More...
 
 generateId ()
 Create unique ID. More...
 
 getBoundary ($boundary, $charSet, $contentType, $encoding)
 Return the start of a message boundary. More...
 
 endBoundary ($boundary)
 Return the end of a message boundary. More...
 
 setMessageType ()
 Set the message type. More...
 
 attachAll ($disposition_type, $boundary)
 Attach all file, string, and binary attachments to the message. More...
 
 encodeFile ($path, $encoding='base64')
 Encode a file attachment in requested format. More...
 
 setError ($msg)
 Add an error message to the error container. More...
 
 serverHostname ()
 Get the server hostname. More...
 
 lang ($key)
 Get an error message in the current language. More...
 
 doCallback ($isSent, $to, $cc, $bcc, $subject, $body, $from)
 Perform a callback. More...
 
- Static Protected Member Functions inherited from PHPMailer
static isShellSafe ($string)
 Fix CVE-2016-10033 and CVE-2016-10045 by disallowing potentially unsafe shell characters. More...
 

Detailed Description

Definition at line 26 of file class.phpmaileroauth.php.

Member Function Documentation

◆ getOAUTHInstance()

PHPMailerOAuth::getOAUTHInstance ( )

Get a PHPMailerOAuthGoogle instance to use.

Returns
PHPMailerOAuthGoogle

Definition at line 63 of file class.phpmaileroauth.php.

References $oauth.

Referenced by smtpConnect().

64  {
65  if (!is_object($this->oauth)) {
66  $this->oauth = new PHPMailerOAuthGoogle(
67  $this->oauthUserEmail,
68  $this->oauthClientSecret,
69  $this->oauthClientId,
70  $this->oauthRefreshToken
71  );
72  }
73  return $this->oauth;
74  }
+ Here is the caller graph for this function:

◆ smtpConnect()

PHPMailerOAuth::smtpConnect (   $options = array())

Initiate a connection to an SMTP server.

Overrides the original smtpConnect method to add support for OAuth.

Parameters
array$optionsAn array of options compatible with stream_context_create() SMTP public
Returns
bool
Exceptions
phpmailerException

Definition at line 85 of file class.phpmaileroauth.php.

References PHPMailer\$Helo, $options, PHPMailer\$Port, PHPMailer\$SMTPSecure, array, defined, PHPMailer\edebug(), getOAUTHInstance(), PHPMailer\getSMTPInstance(), PHPMailer\lang(), and PHPMailer\serverHostname().

86  {
87  if (is_null($this->smtp)) {
88  $this->smtp = $this->getSMTPInstance();
89  }
90 
91  if (is_null($this->oauth)) {
92  $this->oauth = $this->getOAUTHInstance();
93  }
94 
95  // Already connected?
96  if ($this->smtp->connected()) {
97  return true;
98  }
99 
100  $this->smtp->setTimeout($this->Timeout);
101  $this->smtp->setDebugLevel($this->SMTPDebug);
102  $this->smtp->setDebugOutput($this->Debugoutput);
103  $this->smtp->setVerp($this->do_verp);
104  $hosts = explode(';', $this->Host);
105  $lastexception = null;
106 
107  foreach ($hosts as $hostentry) {
108  $hostinfo = array();
109  if (!preg_match('/^((ssl|tls):\/\/)*([a-zA-Z0-9\.-]*):?([0-9]*)$/', trim($hostentry), $hostinfo)) {
110  // Not a valid host entry
111  continue;
112  }
113  // $hostinfo[2]: optional ssl or tls prefix
114  // $hostinfo[3]: the hostname
115  // $hostinfo[4]: optional port number
116  // The host string prefix can temporarily override the current setting for SMTPSecure
117  // If it's not specified, the default value is used
118  $prefix = '';
119  $secure = $this->SMTPSecure;
120  $tls = ($this->SMTPSecure == 'tls');
121  if ('ssl' == $hostinfo[2] or ('' == $hostinfo[2] and 'ssl' == $this->SMTPSecure)) {
122  $prefix = 'ssl://';
123  $tls = false; // Can't have SSL and TLS at the same time
124  $secure = 'ssl';
125  } elseif ($hostinfo[2] == 'tls') {
126  $tls = true;
127  // tls doesn't use a prefix
128  $secure = 'tls';
129  }
130  //Do we need the OpenSSL extension?
131  $sslext = defined('OPENSSL_ALGO_SHA1');
132  if ('tls' === $secure or 'ssl' === $secure) {
133  //Check for an OpenSSL constant rather than using extension_loaded, which is sometimes disabled
134  if (!$sslext) {
135  throw new phpmailerException($this->lang('extension_missing').'openssl', self::STOP_CRITICAL);
136  }
137  }
138  $host = $hostinfo[3];
139  $port = $this->Port;
140  $tport = (integer)$hostinfo[4];
141  if ($tport > 0 and $tport < 65536) {
142  $port = $tport;
143  }
144  if ($this->smtp->connect($prefix . $host, $port, $this->Timeout, $options)) {
145  try {
146  if ($this->Helo) {
147  $hello = $this->Helo;
148  } else {
149  $hello = $this->serverHostname();
150  }
151  $this->smtp->hello($hello);
152  //Automatically enable TLS encryption if:
153  // * it's not disabled
154  // * we have openssl extension
155  // * we are not already using SSL
156  // * the server offers STARTTLS
157  if ($this->SMTPAutoTLS and $sslext and $secure != 'ssl' and $this->smtp->getServerExt('STARTTLS')) {
158  $tls = true;
159  }
160  if ($tls) {
161  if (!$this->smtp->startTLS()) {
162  throw new phpmailerException($this->lang('connect_host'));
163  }
164  // We must resend HELO after tls negotiation
165  $this->smtp->hello($hello);
166  }
167  if ($this->SMTPAuth) {
168  if (!$this->smtp->authenticate(
169  $this->Username,
170  $this->Password,
171  $this->AuthType,
172  $this->Realm,
173  $this->Workstation,
174  $this->oauth
175  )
176  ) {
177  throw new phpmailerException($this->lang('authenticate'));
178  }
179  }
180  return true;
181  } catch (phpmailerException $exc) {
182  $lastexception = $exc;
183  $this->edebug($exc->getMessage());
184  // We must have connected, but then failed TLS or Auth, so close connection nicely
185  $this->smtp->quit();
186  }
187  }
188  }
189  // If we get here, all connection attempts have failed, so close connection hard
190  $this->smtp->close();
191  // As we've caught all exceptions, just report whatever the last one was
192  if ($this->exceptions and !is_null($lastexception)) {
193  throw $lastexception;
194  }
195  return false;
196  }
getOAUTHInstance()
Get a PHPMailerOAuthGoogle instance to use.
edebug($str)
Output debugging info via user-defined method.
serverHostname()
Get the server hostname.
Create styles array
The data for the language used.
getSMTPInstance()
Get an instance to use for SMTP operations.
defined( 'APPLICATION_ENV')||define( 'APPLICATION_ENV'
Definition: bootstrap.php:27
lang($key)
Get an error message in the current language.
if(!isset($_REQUEST['ReturnTo'])) if(!isset($_REQUEST['AuthId'])) $options
Definition: as_login.php:20
+ Here is the call graph for this function:

Field Documentation

◆ $oauth

PHPMailerOAuth::$oauth = null
protected

Definition at line 57 of file class.phpmaileroauth.php.

Referenced by getOAUTHInstance().

◆ $oauthClientId

PHPMailerOAuth::$oauthClientId = ''

Definition at line 44 of file class.phpmaileroauth.php.

◆ $oauthClientSecret

PHPMailerOAuth::$oauthClientSecret = ''

Definition at line 50 of file class.phpmaileroauth.php.

◆ $oauthRefreshToken

PHPMailerOAuth::$oauthRefreshToken = ''

Definition at line 38 of file class.phpmaileroauth.php.

◆ $oauthUserEmail

PHPMailerOAuth::$oauthUserEmail = ''

Definition at line 32 of file class.phpmaileroauth.php.


The documentation for this class was generated from the following file: