<<

NAME

ProductOpener::Mail - sends emails to admin and producers. Moreover, replies to user queries.

SYNOPSIS

ProductOpener::Mail is used to send emails from the contact address of the Open Food Facts to users, admin, and producers.

    use ProductOpener::Mail qw/:all/;

        $contact_email = 'contact@openbeautyfacts.org';
        $admin_email = 'stephane@openfoodfacts.org';
        $producers_email = 'producers@openfoodfacts.org';

DESCRIPTION

The module implements the sending of emails from the Open Food Facts contact email address to users, admin, and producers. These emails can be used to reply to user queries, submit feedback, or to request access from admin and producers.

CONSTANTS

LOG_EMAIL_START

Text used before logging an email

LOG_EMAIL_END

Text used after logging an email

FUNCTIONS

_send_email($mail)

Secure way to send an email (private method)

Depending on $log_emails configuration it might just log the email instead of sending it.

Errors are logged.

Arguments

Email::Stuffer object $mail

The email should be ready to be send

send_email( USER_REF, SUBJECT, TEXT )

send_email() sends a plain text email from the contact email of Open Food Facts to the email passed as an argument.

Arguments

The first argument is a hash reference. The other two arguments are scalar variables that consist of email subject and body.

Input keys: user data

The hash must contain values for the following keys:

- email -> user email - name -> user name

Return Values

The function returns a 1 or 0 depending on the evaluation of the email sent or not.

If the function catches any error during evaluation it returns 1 indicating an error. On the other hand, if there was no error, it returns 0 indicating that the email has been sent successfully.

send_html_email( USER_REF, SUBJECT, HTML_CONTENT )

send_html_email() sends an HTML email from the contact email of Open Food Facts to the email passed as an argument.

Arguments

The first argument is a hash reference. The other two arguments are scalar variables that consist of email subject and HTML content.

Input keys: user data

The hash must contain values for the following keys:

- email -> user email - name -> user name

Return Values

The function returns a 1 or 0 depending on the evaluation of the email sent or not.

If the function catches any error during evaluation it returns 1 indicating an error. On the other hand, if there was no error, it returns 0 indicating that the email has been sent successfully.

get_html_email_content ($filename, $lang )

Fetch the HTML email content in $BASE_DIRS{LANG}/emails. If a translation is available for the requested language, we provide the translated version otherwise English is the default.

Arguments

$filename

The HTML file name (ex: user_welcome.html)

$lang

The 2-letter language code

Return Values

The HTML string or undef if the file does not exists or is not readable.

FUNCTIONS

send_email_to_admin( SUBJECT, TEXT )

send_email_to_admin() sends email from the contact email of Open Food Facts to the admin.

Arguments

Two scalar variables that contain the email subject and body are passed as an argument.

Return Values

The function returns a 1 or 0 depending on the evaluation of the email sent or not.

If the function catches any error during evaluation it returns 1 indicating an error. On the other hand, if there was no error, it returns 0 indicating that the email has been sent successfully.

FUNCTIONS

send_email_to_producers_admin( SUBJECT, TEXT )

send_email_to_producers_admin() sends email from the contact email of Open Food Facts to producers admin.

Arguments

Two scalar variables that contain the email subject and body are passed as an argument.

Return Values

The function returns a 1 or 0 depending on the evaluation of email sent or not.

If the function catches any error during evaluation it returns 1 indicating an error. On the other hand, if there was no error, it returns 1 indicating that email has sent successfully.

<<