Skip to the content
Documentation
Help Start
Reading in:
  • German: 9,075 of 9,075 pages
About the help in other languages
All help pages

Notifications and mail from applications

Send mail from an application correctly - eZMail with a sender and a category, the mail gate and preferences, transports and the file transport for testing, notification event types and handlers, and templates for mail.

Download as PDF

Address: https://doc.exponential.earth/exphelp/viewer/help/creators/app-creators/notifications-and-mail.md

On this page

Notifications and mail from applications

This page is for application creators whose application sends mail: confirmations, reminders, reports. Exponential passes every mail through a mail gate that applies recipients' preferences, and has a notification system for mail triggered by content events (Mail preferences for developers, Notifications for developers).

Contents

  1. Sending a mail
  2. Categories and the gate
  3. Transports and testing
  4. Notifications on content events
  5. Rules

Sending a mail

$ini = eZINI::instance();
$mail = new eZMail();
$mail->setSender( $ini->variable( 'MailSettings', 'EmailSender' ) ?: $ini->variable( 'MailSettings', 'AdminEmail' ) );
$mail->addReceiver( $address );
$mail->setSubject( $subject );
$mail->setBody( $text );
$mail->setCategory( 'events' );
eZMailTransport::send( $mail );

Build the body from a template ($tpl->fetch( 'design:expdemo/mail/reminder.tpl' )) so sites can change the wording.

Categories and the gate

  • Every mail has a category (setCategory()); a category is essential (always sent: security, orders, legal) or optional (only to recipients who turned it on).
  • eZMailTransport::send() hands every mail to expMailGate::dispatch(), which decides per recipient, adds the footer and unsubscribe headers, and logs the blocked ones.
  • Mail without a category is sent unchanged and logged as uncategorized; give every mail a category.
  • A category of your own is declared in settings (3. A category of your own).

Transports and testing

site.ini [MailSettings] Transport is sendmail, smtp or file; the file transport writes each mail to a file, which is how to test without sending (10.4 Mail, 8. Testing without sending mail). An override in settings/override/ wins over a siteaccess setting: check which transport is really in effect with ./console exp:ini where site.ini/MailSettings/Transport <siteaccess> before a test.

Notifications on content events

For "tell people when something is published", write a notification event type and a handler instead of sending mail in a workflow: the notification system collects events, lets users subscribe and sends in the frequent cron part (2. An event type and a handler).

Rules

  • Always set a sender; never a visitor's address as From.
  • Test addresses end in reserved domains (example.com, .invalid); never mail real people from a test.
  • Do not split recipient lists yourself; the gate does, with each recipient's own unsubscribe link.
  • Slow or bulk mail goes through a queue or cron, not the web request.

Become an Exponential Partner

Partners share their information, provide funding, contribute back and develop the products with us, and that is how Exponential grows. A partner website and dashboard are planned for mid-2027: please become a partner today to speed up our growth rate and land new features faster.

Something wrong on this page? Report an error

Documentation license

This documentation is free documentation, licensed under the GNU Free Documentation License 1.3 or later.

Exponential Copyright © 1998-2026 Exponential Foundation and 7x