• PHP reference
  • Email

EmailComposer

class EmailComposer

A simple class to automate sending HTML email to Scholica users or email addresses. A usage sample can be found here.

Properties

string $default_address

Default FROM address (defaults to noreply@scholica.com).

string $attribution_name

Attribution string, adding in the form of (via XXX) to the FROM name.

string $header_icon

Header block icon. Accepts either a URL or a Scholica file ID.

string $header_color

Header block background color. Any valid CSS HEX color code string, make sure to include the pound sign (#).

Methods

__construct(Community $community = null)

Create a new class instance.

Parameters

setSubject(string $subject)

Set the email's subject. This is also displayed in the email header bar.

Parameters

  • string $subject

setContent(string $html)

Set the HTML content for the email.

Parameters

  • string $html

setTo(User|string $user, string $address = null)

Set the email recipient. Either supply a User class instance and omit the second arguments, or name and email as two string arguments.

Parameters

  • User|string $user
  • string $address

setFrom(User|string $user, string $address = null, boolean $attribution = true, boolean $forcefrom = false)

Set the email sender. Either supply a User class instance and omit the second arguments, or name and email as two string arguments. When $attribution is set to true, the 'From' name will end in '(via Scholica)'.

If $forcefrom is set to true, the email is sent from the email address you specified. If set to false (default), only the Reply-To email address is set to the specified address. The From address will be set to a general 'noreply' address to decrease the chance of the email ending up in the SPAM box of the recipient.

Parameters

  • User|string $user
  • string $address
  • boolean $attribution
  • boolean $forcefrom

setHeader(string $name, string $value)

Add a custom email header to the envelope.

Parameters

  • string $name
  • string $value

object send()

Send the email.

Return Value

  • object