<% include( '/elements/header.html', 'Developer Documentation' ) %> <& /elements/menubar.html, 'Freeside Perl Modules' => $fsurl.'docs/library/FS.html', 'Complete Index' => $fsurl.'docs/library/index.html', &>

FS::msg_template::email

NAME

FS::msg_template::email - Construct email notices with Text::Template.

DESCRIPTION

FS::msg_template::email is a message processor in which the template contains Text::Template strings for the message subject line and body, and the message is delivered by email.

Currently the from_addr and bcc_addr fields used by this processor are in the main msg_template table.

METHODS

insert [ CONTENT ]

Adds this record to the database. If there is an error, returns the error, otherwise returns false.

A default (no locale) FS::template_content object will be created. CONTENT is an optional hash containing 'subject' and 'body' for this object.

replace [ OLD_RECORD ] [ CONTENT ]

Replaces the OLD_RECORD with this one in the database. If there is an error, returns the error, otherwise returns false.

CONTENT is an optional hash containing 'subject', 'body', and 'locale'. If supplied, an FS::template_content object will be created (or modified, if one already exists for this locale).

content_locales

Returns a hashref of the FS::template_content objects attached to this template, with the locale as key.

prepare OPTION => VALUE

Fills in the template and returns an FS::cust_msg object.

Options are passed as a list of name/value pairs:

cust_main

Customer object

object

Additional context object (currently, can be a cust_main, cust_pkg, cust_bill, cust_pay, cust_pay_pending, or svc_(acct, phone, broadband, domain) ). If the object is a svc_*, its cust_pkg will be fetched and used for substitution.

As a special case, this may be an arrayref of two objects. Both objects will be available for substitution, with their field names prefixed with 'new_' and 'old_' respectively. This is used in the rt_ticket export when exporting "replace" events.

from_config

Configuration option to use as the source address, based on the customer's agentnum. If unspecified (or the named option is empty), 'invoice_from' will be used.

The from_addr field in the template takes precedence over this.

to

Destination address. The default is to use the customer's invoicing_list addresses. Multiple addresses may be comma-separated.

substitutions

A hash reference of additional substitutions

msgtype

A string identifying the kind of message this is. Currently can be "invoice", "receipt", "admin", or null. Expand this list as necessary.

override_content

A string to use as the HTML body; if specified, replaces the entire body of the message. This should be used ONLY by FS::report_batch and may go away in the future.

attach

A MIME::Entity (or arrayref of them) to attach to the message.

to_contact_classnum

Set a string containing a comma-separated list. This list may contain:

- the text "invoice" indicating contacts with invoice_dest flag should be included - the text "message" indicating contacts with message_dest flag should be included - numbers representing classnum id values for email contact classes. If any classnum are present, emails should only be sent to contact_email addresses where contact_email.classnum contains one of these classes. The classnum 0 also includes where contact_email.classnum IS NULL

If neither 'invoice' nor 'message' has been specified, this method will behave as if 'invoice' had been selected

render OPTION => VALUE ...

Fills in the template and renders it to a PDF document. Returns the name of the PDF file.

Options are as for 'prepare', but 'from' and 'to' are meaningless.

print OPTIONS

Render a PDF and send it to the printer. OPTIONS are as for 'render'.

content LOCALE

Returns the FS::template_content object appropriate to LOCALE, if there is one. If not, returns the one with a NULL locale.

send_prepared CUST_MSG

Takes the CUST_MSG object and sends it to its recipient. The "smtpmachine" configuration option will be used to find the outgoing mail server.

BUGS

SEE ALSO

FS::Record, schema.html from the base documentation.

POD ERRORS

Hey! The above document had some coding errors, which are explained below:

Around line 518:

=cut found outside a pod block. Skipping to next block.

<% include ('/elements/footer.html' ) %>