\OCP\MailIMailer

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' => 'ownCloud 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

Summary

Methods
Constants
createMessage()
send()
validateMailAddress()
No constants found
No protected methods found
N/A
No private methods found
N/A

Methods

createMessage()

createMessage() : \OC\Mail\Message

Creates a new message object that can be passed to send()

Returns

\OC\Mail\Message

send()

send(\OC\Mail\Message  $message) : array<mixed,string>

Send the specified message. Also sets the from address to the value defined in config.php if no-one has been passed.

Parameters

\OC\Mail\Message $message

Message to send

Throws

\Exception

In case it was not possible to send the message. (for example if an invalid mail address has been supplied.)

Returns

array<mixed,string> —

Array with failed recipients. Be aware that this depends on the used mail backend and therefore should be considered

validateMailAddress()

validateMailAddress(string  $email) : boolean

Checks if an e-mail address is valid

Parameters

string $email

Email address to be validated

Returns

boolean —

True if the mail address is valid, false otherwise