Mailer¶
-
class
OC\Mail\
Mailer
¶ - Class Mailer provides some basic functions to create a mail message that can be used in combination with\OC\Mail\Message.Example usage:$mailer = \OC::$server->getMailer();$message = $mailer->createMessage();$message->setSubject(‘Your Subject’);$message->setFrom(array('cloud@domain.org‘ => ‘ownCloud Notifier’));$message->setTo(array('recipient@domain.org‘ => ‘Recipient’));$message->setBody(‘The message text’, ‘text/html’);$mailer->send($message);This message can then be passed to send() of \OC\Mail\Mailer
Source: lib/private/Mail/Mailer.php#72 Implements: OCP\Mail\IMailer
Properties¶
Methods¶
-
public
OC\Mail\Mailer::
__construct
($config, $logger, $defaults, $urlGenerator, $l10n, $dispatcher, $l10nFactory)¶ Source: Parameters: - $config (
OCP\IConfig
) - $logger (
OCP\ILogger
) - $defaults (
OCP\Defaults
) - $urlGenerator (
OCP\IURLGenerator
) - $l10n (
OCP\IL10N
) - $dispatcher (
OCP\EventDispatcher\IEventDispatcher
)
- $config (
-
public
OC\Mail\Mailer::
createMessage
()¶ - Creates a new message object that can be passed to send()
Source: lib/private/Mail/Mailer.php#119 Returns: \OCP\Mail\IMessage
-
public
OC\Mail\Mailer::
createAttachment
($data=null, $filename=null, $contentType=null)¶ Source: Parameters: - $data (string | null)
- $filename (string | null)
- $contentType (string | null)
Returns: Since: 13.0.0
-
public
OC\Mail\Mailer::
createAttachmentFromPath
($path, $contentType=null)¶ Source: Parameters: - $path (string)
- $contentType (string | null)
Returns: Since: 13.0.0
-
public
OC\Mail\Mailer::
createEMailTemplate
($emailId, $data=[])¶ - Creates a new email template object
Source: Parameters: - $emailId (string)
- $data (array)
Returns: Since: 12.0.0
-
public
OC\Mail\Mailer::
send
($message)¶ - Send the specified message. Also sets the from address to the value defined in config.phpif no-one has been passed.
Source: Parameters: - $message (
OCP\Mail\IMessage
|\OC\Mail\Message
) Message to send
Returns: string[] Array with failed recipients. Be aware that this depends on the used mail backend and therefore should be considered
Throws: \Exception
In case it was not possible to send the message. (for example if an invalid mail address has been supplied.) - $message (
-
public
OC\Mail\Mailer::
validateMailAddress
($email)¶ - Checks if an e-mail address is valid
Source: Parameters: - $email (string) Email address to be validated
Returns: bool True if the mail address is valid, false otherwise
-
protected
OC\Mail\Mailer::
convertEmail
($email)¶ - SwiftMailer does currently not work with IDN domains, this function therefore converts the domainsFIXME: Remove this once SwiftMailer supports IDN
Source: Parameters: - $email (string)
Returns: string Converted mail address if `idn_to_ascii` exists
-
protected
OC\Mail\Mailer::
getInstance
()¶ Source: lib/private/Mail/Mailer.php#252
-
protected
OC\Mail\Mailer::
getSmtpInstance
()¶ - Returns the SMTP transport
Source: lib/private/Mail/Mailer.php#277 Returns: \Swift_SmtpTransport
-
protected
OC\Mail\Mailer::
getSendMailInstance
()¶ - Returns the sendmail transport
Source: lib/private/Mail/Mailer.php#304 Returns: \Swift_SendmailTransport