This is an old revision of the document!


Send emails with Piwigo

This page only applies to Piwigo 2.6 and newer.

Introduction

Piwigo integrates a powerful mailing function compatible with standard PHP mail() function and SMTP servers. It is base on PHPMailer and Emogrifier libraries.

There are four functions to send emails:

  • pwg_mail() - the main one
  • pwg_mail_admins() - to send emails to all admins
  • pwg_mail_groups() - to send emails to a specific group
  • pwg_mail_notification_admins() - dedicated to administrative emails

Basic usage

pwg_mail() takes three parameters, for basic usage you only need to use the first and the second one.

The first parameter is the recipient(s) of the mail, it can be either:

  • a single email: name@domain.com
  • a single email with associated name: Name <name@ domain.com>
  • a comma separated list of emails (with or without associated names)
  • an array of hashmaps containing email and name keys:
$recipients = array(
  array('name' => 'Name 1', 'email' => 'name1@domain.com'),
  array('name' => 'Name 2', 'email' => 'name2@domain.com'),
);

The second parameter is an array of options:

  • from - sender of the email [defaults to webmaster email and gallery name]
  • Cc - carbon copy recipients as array [defaults to empty]
  • Bcc - blind carbon copy recipients as array [defaults to empty]
  • subject - subject of the email [defaults to 'Piwigo']
  • content - content of the email
  • content_format - text/html or text/plain [defaults to 'text/plain']
  • email_format - text/html or text/plain [defaults to 'text/html'] will be forced to 'text/plain' if webmaster disabled HTML emails
  • theme - clear or dark [defaults to $conf['mail_theme']]
  • mail_title - main title in email corpus [defaults to $conf['gallery_title']]
  • mail_subtitle - subtitle in email corpus [defaults to subject]]
About mail_title and mail_subtitle

If you set subject to [something] something else and leave mail_title and mail_subtitle empty, you will get:
mail_title = something
mail_subtitle = something else
This is for backward compatibility only.

Example

<code php> include_once(PHPWG_ROOT_PATH . 'include/functions_mail.inc.php');

pwg_mail(

array(, array(
'content_format' => 'text/html',
'subject' => 'Test',
'email_format' => 'text/html',
),
array(
  'filename' => 'apk',
  'dirname' => PHPWG_ROOT_PATH.'test',
  'assign' => array(
    'MY_VAR' => 'Bonjour',
    ),
  )
);
 
Back to top
dev/send_emails_with_piwigo.1383764561.txt.gz · Last modified: 2013/11/06 19:02 by mistic100
 
 
github twitter newsletter Donate Piwigo.org © 2002-2024 · Contact