Login +

Reference Guide / SLS_Email

SLS_Email1 is a class for sending emails via SMTP or by the basic PHP mail() function.

Accessibility

At Controller level, you access it directly by instantiating the class:

$email = new SLS_Email($host="", $port=25, $user="", $pwd="");

If you do not specify any parameters in the constructor, SillySmart will retrieve parameters from mails.xml ; if we don’t have specified these parameters, the PHP mail() function will be used.

Class methods

- Open the SMTP connection, use the openConnection() function:

$email->openConnection();

- To specify the encoding of the message, use the setCharset() function:

$email->setCharset("UTF-8");

- To add recipients to the message, use the addRecipient() function:

$email->addRecipient($email, "To");

- To specify the "sender" of the message, use the setSender() function:

$email->setSender($sender, $senderName);

- To specify the "reply" of the message, use the setReply() function:

$email->setReply($reply, $replyName);

- To specify the "return" of the message, use the setReturn() function:

$email->setReturn($return, $returnName);

- To specify the "X-Mailer" of the message, use the setXMailer() function:

$email->setXMailer($xMailer);

- To specify the subject mail, use the setSubject() function:

$email->setSubject($subject);

- To specify the HTML message, use the setHtml() function:

$email->setHtml($msg);

- To specify the plain text, use the setPlain() function:

$email->setPlain(strip_tags(SLS_String::br2nl($msg)));

- To add attachments to the message, use the addAttachment() function:

$email->addAttachment($filePath);

- To add embedded files in the message, use the addEmbedded() function:

$email->addEmbedded($raw,$fileName);

- To prepare the mail sending, use the compileMail() function:

$email->compileMail();

- To send the message, use the send() function:

$email->send();

- To close the SMTP connection, use the closeConnection() function:

$email->closeConnection();

Related :

References

  1. SLS_Email - Send mail from a distant SMTP
  2. SLS_String - Tool SLS_String - String Treatment