HTML Logo by World Wide Web Consortium (www.w3.org). Click to learn more about our commitment to accessibility and standards.

ocPortal Developer's Guide: The mailer

» Return to Contents



ocPortal needs to send e-mails to people for many reasons; to alert the admin to hackattacks, to inform people of points transfers etc.

sources/mail.php

Global_functions_mail.php

Function summary

void init__mail ()
string _mail_img_rep_callback (array matches)
string _mail_css_rep_callback (array matches)
string _indent_callback (array matches)
string _title_callback (array matches)
string _box_callback (array matches)
string comcode_to_clean_text (string message_plain)
?tempcode mail_wrap (string subject_tag, LONG_TEXT message_raw, ?array to_email, ?mixed to_name, EMAIL from_email, string from_name, integer priority, ?array attachments, boolean no_cc, ?MEMBER as, boolean as_admin, boolean in_html, boolean coming_out_of_queue, ID_TEXT mail_template)
string filter_css (string css, string context)
void form_to_email_entry_script ()
void form_to_email (?string subject, string intro, ?array fields, ?string to_email)

void init__mail()

Standard code module initialisation function.

Parameters…

(No return value)


Return to the function index for this class Expand: View the source code to this function

string _mail_img_rep_callback(array matches)

Replace an HTML img tag such that it is cid'd. Callback for preg_replace_callback.

Parameters…

Name matches
Description Matches
Type array

Returns…

Description Replacement
Type string

Return to the function index for this class Expand: View the source code to this function

string _mail_css_rep_callback(array matches)

Replace CSS image references such that it is cid'd. Callback for preg_replace_callback.

Parameters…

Name matches
Description Matches
Type array

Returns…

Description Replacement
Type string

Return to the function index for this class Expand: View the source code to this function

string _indent_callback(array matches)

Indent text lines. Callback for preg_replace_callback.

Parameters…

Name matches
Description Matches
Type array

Returns…

Description Replacement
Type string

Return to the function index for this class Expand: View the source code to this function

string _title_callback(array matches)

Make titles readable. Callback for preg_replace_callback.

Parameters…

Name matches
Description Matches
Type array

Returns…

Description Replacement
Type string

Return to the function index for this class Expand: View the source code to this function

string _box_callback(array matches)

Make boxes readable. Callback for preg_replace_callback.

Parameters…

Name matches
Description Matches
Type array

Returns…

Description Replacement
Type string

Return to the function index for this class Expand: View the source code to this function

string comcode_to_clean_text(string message_plain)

Make some Comcode more readable.

Parameters…

Name message_plain
Description Comcode text to change
Type string

Returns…

Description Clean text
Type string

Return to the function index for this class Expand: View the source code to this function

?tempcode mail_wrap(string subject_tag, LONG_TEXT message_raw, ?array to_email, ?mixed to_name, EMAIL from_email, string from_name, integer priority, ?array attachments, boolean no_cc, ?MEMBER as, boolean as_admin, boolean in_html, boolean coming_out_of_queue, ID_TEXT mail_template)

Attempt to send an e-mail to the specified recipient. The mail will be forwarding to the CC address specified in the options (if there is one, and if not specified not to cc).The mail will be sent in dual HTML/text format, where the text is the unconverted comcode source: if a member does not read HTML mail, they may wish to fallback to reading that.

Parameters…

Name subject_tag
Description The subject of the mail in plain text
Type string

Name message_raw
Description The message, as Comcode
Type LONG_TEXT

Name to_email
Description The destination (recipient) e-mail addresses [array of strings] (NULL: site staff address)
Default value
Type ?array

Name to_name
Description The recipient name. Array or string. (NULL: site name)
Default value
Type ?mixed

Name from_email
Description The from address (blank: site staff address)
Default value
Type EMAIL

Name from_name
Description The from name (blank: site name)
Default value
Type string

Name priority
Description The message priority (1=urgent, 3=normal, 5=low)
Default value 3
Type integer
Value range 1 5

Name attachments
Description An list of attachments (each attachment being a map, path=>filename) (NULL: none)
Default value
Type ?array

Name no_cc
Description Whether to NOT CC to the CC address
Default value boolean-false
Type boolean

Name as
Description Convert comcode->tempcode as this member (a privilege thing: we don't want people being able to use admin rights by default!) (NULL: guest)
Default value
Type ?MEMBER

Name as_admin
Description Replace above with arbitrary admin
Default value boolean-false
Type boolean

Name in_html
Description HTML-only
Default value boolean-false
Type boolean

Name coming_out_of_queue
Description Whether to bypass queueing, because this code is running as a part of the queue management tools
Default value boolean-false
Type boolean

Name mail_template
Description The template used to show the email
Default value MAIL
Type ID_TEXT

Returns…

Description A full page (not complete XHTML) piece of tempcode to output (NULL: it worked so no tempcode message)
Type ?tempcode

Return to the function index for this class Expand: View the source code to this function

string filter_css(string css, string context)

Filter out any CSS selector blocks from the given CSS if they definitely do not affect the given (X)HTML.Whilst this is a clever algorithm, it isn't so clever as to actually try and match each selector against a DOM tree. If any segment of a compound selector matches, match is assumed.

Parameters…

Name css
Description CSS
Type string

Name context
Description (X)HTML context under which CSS is filtered
Type string

Returns…

Description Filtered CSS
Type string

Return to the function index for this class Expand: View the source code to this function

void form_to_email_entry_script()

Entry script to process a form that needs to be emailed.

Parameters…

(No return value)


Return to the function index for this class Expand: View the source code to this function

void form_to_email(?string subject, string intro, ?array fields, ?string to_email)

Send the posted form over email to the staff address.

Parameters…

Name subject
Description The subject of the email (NULL: from posted subject parameter).
Default value
Type ?string

Name intro
Description The intro text to the mail.
Default value
Type string

Name fields
Description A map of fields to field titles to transmit. (NULL: all posted fields, except subject and email)
Default value
Type ?array

Name to_email
Description Email address to send to (NULL: look from post environment / staff address).
Default value
Type ?string

(No return value)


Return to the function index for this class Expand: View the source code to this function