Opened 7 years ago

Closed 7 years ago

Last modified 7 years ago

#1835 closed feature request (fixed)

o.o.mail: Email composition helper

Reported by: bergie Owned by: bergie
Priority: major Milestone: 8.09.9 Ragnaroek
Component: MidCOM component Version: 8.09 Ragnaroek
Keywords: Cc:

Description

org.openpsa.mail has very powerful email sending features, but composing HTML emails still has to be done manually.

Instead, we should have a helper for this.

Usage from component

// Message content template, with variables surrounded with __ and __
$message_text = 'Hi, __user__

Welcome to our cool Midgard site!

The Team';

// Variables with their replacement values
$message_strings = array
(
    'user' => $_MIDCOM->auth->user->name,
);

// MidCOM style template we want to use for the HTML mail
$template = 'welcome-email';

// Composite the message
$mail = org_openpsa_mail::compose($template, $message_text, $message_strings);

// Fill recipient, sender and subject
$mail->to = $_MIDCOM->auth->user->get_storage()->email;
$mail->from = 'webmaster@example.net';
$mail->subject = 'Welcome to the website!';

// Send the message
$mail->send();

In a simple case the template could be something like:

<p><img src="http://www.midgard-project.org/midcom-static/style_midgard2007/midgard-bubble-104x104.gif" alt="Midgard" /></p>
<?php
echo nl2br($data['email_message_text']);
?>

Change History (3)

comment:1 Changed 7 years ago by bergie

  • Resolution set to fixed
  • Status changed from new to closed

(In [26213]) HTML and text email composition helper, fixes #1835

comment:2 Changed 7 years ago by rambo

(In [26346]) pass the widget_id to the creation handler url, fixes #1835

comment:3 Changed 7 years ago by rambo

r26346 should have been against #1853

Note: See TracTickets for help on using tickets.