NAME

DADA::App::FormatMessages


SYNOPSIS

 my $fm = DADA::App::FormatMessages->new(-List => $list); 
 
 # The subject of the message is...  
   $fm->Subject('This is the subject!'); 
   
 # Use information you find in the headers 
  $fm->use_header_info(1);
 
 # Use the list template   
   $fm->use_list_template(1); 
 
 # Use the email template.
   $fm->use_email_templates(1);  
 
 # Consider this message as if it's from a discussion list
   $fm->treat_as_discussion_msg(1);
 
 my ($header_str, $body_str) = $fm->format_headers_and_body(-msg => $msg);
 
 # (... later on... 
 
 use DADA::MAilingList::Settings; 
 use DADA::Mail::Send; 
 
 my $ls = DADA::MailingList::Settings->new(-List => $list); 
 my $mh = DADA::Mail::Send->new($ls->get); 
 
 $mh->send(
           $mh->return_headers($header_str), 
                   Body => $body_str,
                  );


DESCRIPTION

DADA::App::FormatMessages is used to get a email message ready for sending to your mailing list. Most of its magic is behind the scenes, and isn't something you have to worry about, but we'll go through some detail.


METHODS

new

 my $fm = DADA::App::FormatMessages->new(-List => $list);

format_headers_and_body

 my ($header_str, $body_str) = $fm->format_headers_and_body(-msg => $msg);

Given a string, $msg, returns two variables; $header_str, which will have all the headers and $body_str, that holds the body of your message.


ACCESSORS

Subject

Set the subject of a message

use_list_template

If set to a true value, will apply the list template to the HTML part of your message

use_email_templates

If set to a true value, will apply your email templates to the HTML/PlainText parts of your message.

treat_as_discussion_msg

When set to a true value, will try the message as if it was from a discussion list.

use_header_info

If set to a true value, will inspect the headers of a message (for example, the From: line) to work with


PRIVATE METHODS

_fix_for_only_html_part

 $entity = $self->_fix_for_only_html_part($entity);

Changes the single part, HTML entity into a multipart/alternative message, with an auto plaintext version.

_format_text

 $entity = $self->_format_text($entity);

Given an MIME::Entity (may be multipart) will attempt to:

_create_multipart_from_html

 $entity = $self->_create_multipart_from_html($entity);

Recursively goes through a multipart entity, changing any non-attachment singlepart HTML message into a multipart/alternative message with an auto-generated PlainText version.

_make_multipart

 $entity = $self->_make_multipart($entity);     
 
Takes a single part entity and changes it to a multipart/alternative message, 
with an autogenerated PlainText version.

_create_plaintext_from_html

 my $PlainText_var = $self->_create_plaintext_from_html($HTML_Ver);
 Given a B<string>, simple converts the HTML to PlainText

_format_headers

 $entity = $self->_format_headers($entity)

Given an entity, will do some transformations on the headers. It will:

_list_name_subject

 my $subject = $self->_list_name_subject($list_name, $subject));

Appends, $list_name onto subject.

_parse_in_list_info

 $data = $self->_parse_in_list_info(-data => $data, 
                                    -type => (PlainText/HTML), 
                                   );
                                                                        
Given a string, changes Dada Mail's pseudo tags into what they represent.

-type can be either PlainText or HTML

_macro_tags

 my $s_link   = $self->_macro_tags(-type => 'subscribe'  ); 
 my $us_link  = $self->_macro_tags(-type => 'unsubscribe');

Explode the various link pseudo tags into a form that will later be interpolated.

-type can be:

_apply_template

$content = $self->_apply_template(-data => $content,
-type => $entity->head->mime_type,
);

Given a string in -data, applies the correct email mailing list template, depending on what -type is passed, this will be either the PlainText or HTML version.

_apply_list_template

 $new_data = $self->_apply_list_template($new_data);

Given a string, will apply the List Template. The List Template is usually used for HTML screens that appear in your web browser.