FacturaScripts

NewMail
in package

Description of NewMail

Table of Contents

Constants

ATTACHMENTS_TMP_PATH  = 'MyFiles/Tmp/Email/'

Properties

$empresa  : Empresa
$fromEmail  : string
$fromName  : string
$fromNick  : string
$signature  : string
$text  : string
$title  : string
$verificode  : string
$footerBlocks  : array<string|int, BaseBlock>
$html  : string
$lowsecure  : bool
$mail  : PHPMailer
$mainBlocks  : array<string|int, BaseBlock>
$template  : string
$blockHandlers  : array<string, callable>
$mailer  : array<string|int, mixed>

Methods

__construct()  : mixed
addAddress()  : NewMail
addAttachment()  : NewMail
Añade un adjunto al correo.
addBCC()  : NewMail
addBlockHandler()  : void
Registra un handler personalizado para un tipo de shortcode de bloque.
addCC()  : NewMail
addFooterBlock()  : NewMail
Añade un bloque al pie del correo.
addMailer()  : void
addMainBlock()  : NewMail
Añade un bloque al cuerpo del correo.
addReplyTo()  : NewMail
bcc()  : NewMail
body()  : NewMail
canSendMail()  : bool
Verifica si se puede enviar el correo.
cc()  : NewMail
create()  : NewMail
getAttachmentNames()  : array<string|int, mixed>
Devuelve los nombres de los archivos adjuntos.
getAttachmentPath()  : string
getAvailableMailboxes()  : array<string|int, mixed>
Devuelve un array con los emails disponibles para el usuario.
getBCCAddresses()  : array<string|int, mixed>
Devuelve un array con los emails con copia oculta.
getCCAddresses()  : array<string|int, mixed>
Devuelve un array con los emails con copia.
getMailer()  : array<string|int, mixed>
getMainBlocks()  : array<string|int, mixed>
Devuelve los bloques del cuerpo del correo.
getTemplate()  : string
getToAddresses()  : array<string|int, mixed>
Devuelve un array con los emails hacia donde va el mensaje.
replyTo()  : NewMail
send()  : bool
Envía el correo.
sendNotification()  : bool
setMailbox()  : NewMail
setTemplate()  : void
setUser()  : NewMail
Establece el usuario que manda el email.
splitEmails()  : array<string|int, mixed>
Separa los emails de una cadena en array.
subject()  : NewMail
test()  : bool
Pruebe la conexión PHPMailer.
to()  : NewMail
addTextOrHtmlBlock()  : void
Añade un HtmlBlock si el texto contiene etiquetas HTML, o un TextBlock si es texto plano.
createBlockFromShortcode()  : BaseBlock|null
Instancia el bloque correspondiente al tipo de shortcode delegando en su método fromShortcode().
getFooterBlocks()  : array<string|int, mixed>
Devuelve los bloques del pie del correo.
parseShortcodeAttributes()  : array<string|int, mixed>
Parsea los atributos de un shortcode en un array clave => valor.
renderHTML()  : void
Renderiza el HTML del correo.
replaceTextToBlock()  : void
Busca shortcodes de bloque en el texto del email y los convierte en objetos BaseBlock.
saveMailSent()  : void
Guarda el correo enviado en la base de datos.
smtpOptions()  : array<string|int, mixed>
Devuelve las opciones SMTP.

Constants

ATTACHMENTS_TMP_PATH

public mixed ATTACHMENTS_TMP_PATH = 'MyFiles/Tmp/Email/'

Properties

$verificode

public string $verificode

$lowsecure

protected bool $lowsecure

$template

protected static string $template = 'NewTemplate.html.twig'

$blockHandlers

private static array<string, callable> $blockHandlers = []

$mailer

private static array<string|int, mixed> $mailer = ['mail' => 'Mail', 'sendmail' => 'SendMail', 'smtp' => 'SMTP']

Methods

__construct()

public __construct() : mixed

addAddress()

public addAddress(string $email[, string $name = '' ]) : NewMail

since version 2023.09

Parameters
$email : string
$name : string = ''
Return values
NewMail

addAttachment()

Añade un adjunto al correo.

public addAttachment(string $path, string $name) : NewMail
Parameters
$path : string
$name : string
Tags
throws
Exception
Return values
NewMail

addBCC()

public addBCC(string $email[, string $name = '' ]) : NewMail

since version 2023.09

Parameters
$email : string
$name : string = ''
Return values
NewMail

addBlockHandler()

Registra un handler personalizado para un tipo de shortcode de bloque.

public static addBlockHandler(string $tag) : void

El callable recibe (array $attrs, string $content) y debe devolver un BaseBlock o null. Ejemplo: NewMail::addBlockHandler('myblock', fn($attrs, $content) => new MyBlock($content));

Parameters
$tag : string

addCC()

public addCC(string $email[, string $name = '' ]) : NewMail

since version 2023.09

Parameters
$email : string
$name : string = ''
Return values
NewMail

addMailer()

public static addMailer(string $key, string $name) : void
Parameters
$key : string
$name : string

addReplyTo()

public addReplyTo(string $address[, string $name = '' ]) : NewMail

since version 2023.09

Parameters
$address : string
$name : string = ''
Return values
NewMail

bcc()

public bcc(string $email[, string $name = '' ]) : NewMail
Parameters
$email : string
$name : string = ''
Return values
NewMail

canSendMail()

Verifica si se puede enviar el correo.

public canSendMail() : bool
Return values
bool

cc()

public cc(string $email[, string $name = '' ]) : NewMail
Parameters
$email : string
$name : string = ''
Return values
NewMail

getAttachmentNames()

Devuelve los nombres de los archivos adjuntos.

public getAttachmentNames() : array<string|int, mixed>
Return values
array<string|int, mixed>

getAttachmentPath()

public static getAttachmentPath(string|null $email, string $folder) : string
Parameters
$email : string|null
$folder : string
Return values
string

getAvailableMailboxes()

Devuelve un array con los emails disponibles para el usuario.

public getAvailableMailboxes() : array<string|int, mixed>
Return values
array<string|int, mixed>

getBCCAddresses()

Devuelve un array con los emails con copia oculta.

public getBCCAddresses() : array<string|int, mixed>
Return values
array<string|int, mixed>

getCCAddresses()

Devuelve un array con los emails con copia.

public getCCAddresses() : array<string|int, mixed>
Return values
array<string|int, mixed>

getMailer()

public static getMailer() : array<string|int, mixed>
Return values
array<string|int, mixed>

getMainBlocks()

Devuelve los bloques del cuerpo del correo.

public getMainBlocks() : array<string|int, mixed>
Return values
array<string|int, mixed>

getTemplate()

public static getTemplate() : string
Return values
string

getToAddresses()

Devuelve un array con los emails hacia donde va el mensaje.

public getToAddresses() : array<string|int, mixed>
Return values
array<string|int, mixed>

replyTo()

public replyTo(string $address[, string $name = '' ]) : NewMail
Parameters
$address : string
$name : string = ''
Return values
NewMail

send()

Envía el correo.

public send() : bool
Tags
throws
Exception
throws
LoaderError
throws
RuntimeError
throws
SyntaxError
Return values
bool

sendNotification()

public sendNotification(string $notificationName, array<string|int, mixed> $params) : bool

since version 2023.09

Parameters
$notificationName : string
$params : array<string|int, mixed>
Tags
throws
Exception
throws
SyntaxError
throws
RuntimeError
throws
LoaderError
Return values
bool

setMailbox()

public setMailbox(string $emailFrom) : NewMail
Parameters
$emailFrom : string
Return values
NewMail

setTemplate()

public static setTemplate(string $template) : void
Parameters
$template : string

splitEmails()

Separa los emails de una cadena en array.

public static splitEmails(string $emails) : array<string|int, mixed>
Parameters
$emails : string
Return values
array<string|int, mixed>

test()

Pruebe la conexión PHPMailer.

public test() : bool
Tags
throws
Exception
Return values
bool

to()

public to(string $email[, string $name = '' ]) : NewMail
Parameters
$email : string
$name : string = ''
Return values
NewMail

addTextOrHtmlBlock()

Añade un HtmlBlock si el texto contiene etiquetas HTML, o un TextBlock si es texto plano.

protected addTextOrHtmlBlock(string $text) : void

Siempre usa la clase Dinamic para que los plugins puedan sobreescribirla.

Parameters
$text : string

createBlockFromShortcode()

Instancia el bloque correspondiente al tipo de shortcode delegando en su método fromShortcode().

protected createBlockFromShortcode(string $type, array<string|int, mixed> $attrs, string $content) : BaseBlock|null
Parameters
$type : string
$attrs : array<string|int, mixed>
$content : string
Return values
BaseBlock|null

getFooterBlocks()

Devuelve los bloques del pie del correo.

protected getFooterBlocks() : array<string|int, mixed>
Return values
array<string|int, mixed>

parseShortcodeAttributes()

Parsea los atributos de un shortcode en un array clave => valor.

protected static parseShortcodeAttributes(string $attrsStr) : array<string|int, mixed>

Soporta comillas simples y dobles: attr="valor" o attr='valor'

Parameters
$attrsStr : string
Return values
array<string|int, mixed>

renderHTML()

Renderiza el HTML del correo.

protected renderHTML() : void
Tags
throws
SyntaxError
throws
RuntimeError
throws
LoaderError

replaceTextToBlock()

Busca shortcodes de bloque en el texto del email y los convierte en objetos BaseBlock.

protected replaceTextToBlock() : void

También detecta HTML entre bloques y lo envuelve en HtmlBlock; el texto plano va a TextBlock. Sintaxis: [blockTipo atributos]contenido[/blockTipo] o [blockTipo atributos] (auto-cierre) Ejemplos: [blockTitle type="h2"]Bienvenido[/blockTitle] [blockText]Párrafo de texto[/blockText] [blockHtml]

  • item
[/blockHtml] [blockButton label="Reservar" href="https://..."] [blockSpace height="20"] Los plugins pueden registrar tipos adicionales con NewMail::addBlockHandler().

saveMailSent()

Guarda el correo enviado en la base de datos.

protected saveMailSent() : void

smtpOptions()

Devuelve las opciones SMTP.

protected smtpOptions() : array<string|int, mixed>
Return values
array<string|int, mixed>

        
On this page

Search results