IMailer
Class IMailer 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(['cloud@domain.org' => 'Nextcloud Notifier']);
$message->setTo(['recipient@domain.org' => 'Recipient']);
$message->setPlainBody('The message text');
$message->setHtmlBody('The <strong>message</strong> text');
$mailer->send($message);
This message can then be passed to send() of \OC\Mail\Mailer
Tags
Table of Contents
- createAttachment() : IAttachment
- createAttachmentFromPath() : IAttachment
- createEMailTemplate() : IEMailTemplate
- Creates a new email template object
- createMessage() : IMessage
- Creates a new message object that can be passed to send()
- send() : string[]
- Send the specified message. Also sets the from address to the value defined in config.php if no-one has been passed.
- validateMailAddress() : bool
- Checks if an e-mail address is valid
Methods
createAttachment()
public
createAttachment([string|null $data = null ][, string|null $filename = null ][, string|null $contentType = null ]) : IAttachment
Parameters
- $data : string|null = null
- $filename : string|null = null
- $contentType : string|null = null
Tags
Return values
IAttachment —createAttachmentFromPath()
public
createAttachmentFromPath(string $path[, string|null $contentType = null ]) : IAttachment
Parameters
- $path : string
- $contentType : string|null = null
Tags
Return values
IAttachment —createEMailTemplate()
Creates a new email template object
public
createEMailTemplate(string $emailId[, array $data = [] ]) : IEMailTemplate
Parameters
- $emailId : string
- $data : array = []
Tags
Return values
IEMailTemplate —createMessage()
Creates a new message object that can be passed to send()
public
createMessage() : IMessage
Tags
Return values
IMessage —send()
Send the specified message. Also sets the from address to the value defined in config.php if no-one has been passed.
public
send(IMessage $message) : string[]
Parameters
- $message : IMessage
-
Message to send
Tags
Return values
string[] —Array with failed recipients. Be aware that this depends on the used mail backend and therefore should be considered
validateMailAddress()
Checks if an e-mail address is valid
public
validateMailAddress(string $email) : bool
Parameters
- $email : string
-
Email address to be validated
Tags
Return values
bool —True if the mail address is valid, false otherwise