Skip to content

Commit

Permalink
Add SMTP account option (used as From: header if any), add ReplyTo: h…
Browse files Browse the repository at this point in the history
…eader
  • Loading branch information
franck-paul committed Sep 17, 2020
1 parent d91a468 commit 7b224f9
Show file tree
Hide file tree
Showing 6 changed files with 75 additions and 41 deletions.
2 changes: 1 addition & 1 deletion _define.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"ContactMe", // Name
"Add a simple contact form on your blog", // Description
"Olivier Meunier and contributors", // Author
'1.10.1', // Version
'1.11', // Version
[
'requires' => [['core', '2.16']], // Dependencies
'permissions' => 'admin', // Permissions
Expand Down
9 changes: 8 additions & 1 deletion _public.php
Original file line number Diff line number Diff line change
Expand Up @@ -142,9 +142,16 @@ public static function contact($args)
unset($cur);
}

if ($core->blog->settings->contactme->cm_smtp_account) {
$from = mail::B64Header($core->blog->name) . ' <' . $core->blog->settings->contactme->cm_smtp_account . '>';
} else {
$from = mail::B64Header($_ctx->contactme['name']) . ' <' . $_ctx->contactme['email'] . '>';
}

# Sending mail
$headers = [
'From: ' . mail::B64Header($_ctx->contactme['name']) . ' <' . $_ctx->contactme['email'] . '>',
'From: ' . $from,
'Reply-To: ' . mail::B64Header($_ctx->contactme['name']) . ' <' . $_ctx->contactme['email'] . '>',
'Content-Type: text/plain; charset=UTF-8;',
'X-Originating-IP: ' . http::realIP(),
'X-Mailer: Dotclear',
Expand Down
9 changes: 8 additions & 1 deletion index.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
$cm_msg_success = $core->blog->settings->contactme->cm_msg_success;
$cm_msg_error = $core->blog->settings->contactme->cm_msg_error;
$cm_use_antispam = $core->blog->settings->contactme->cm_use_antispam;
$cm_smtp_account = $core->blog->settings->contactme->cm_smtp_account;

$antispam_enabled = $core->plugins->moduleExists('antispam');

Expand Down Expand Up @@ -50,6 +51,7 @@
$cm_form_caption = $_POST['cm_form_caption'];
$cm_msg_success = $_POST['cm_msg_success'];
$cm_msg_error = $_POST['cm_msg_error'];
$cm_smtp_account = $_POST['cm_smtp_account'];

if (empty($_POST['cm_recipients'])) {
throw new Exception(__('No recipients.'));
Expand Down Expand Up @@ -91,6 +93,7 @@
$core->blog->settings->contactme->put('cm_form_caption', $cm_form_caption, 'string', 'ContactMe form caption');
$core->blog->settings->contactme->put('cm_msg_success', $cm_msg_success, 'string', 'ContactMe success message');
$core->blog->settings->contactme->put('cm_msg_error', $cm_msg_error, 'string', 'ContactMe error message');
$core->blog->settings->contactme->put('cm_smtp_account', $cm_smtp_account, 'string', 'ContactMe SMTP account');

if ($antispam_enabled) {
$core->blog->settings->contactme->put('cm_use_antispam', !empty($_POST['cm_use_antispam']), 'boolean', 'ContactMe should use comments spam filter');
Expand Down Expand Up @@ -142,7 +145,11 @@
form::field('cm_recipients', 30, 512, html::escapeHTML($cm_recipients), 'maximal', '', false, 'required placeholder="' . __('Email') . '"') . '</p>' .
'<p><label for="cm_subject_prefix">' . __('E-Mail subject prefix:') . '</label> ' .
form::field('cm_subject_prefix', 30, 128, html::escapeHTML($cm_subject_prefix)) . '</p>' .
'<p class="form-note">' . __('This will be prepend to e-mail subject') . '</p>';
'<p class="form-note">' . __('This will be prepend to e-mail subject') . '</p>' .
'<p><label for="cm_smtp_account">' . __('SMTP account (optional):') . '</label> ' .
form::field('cm_smtp_account', 30, 512, html::escapeHTML($cm_smtp_account), 'maximal', '', false) . '</p>' .
'<p class="form-note">' . __('This will be use as e-mail sender. Note that the sent e-mails will have a Reply-To filled with your correspondent e-mail.') . '</p>';


# Antispam options
if ($antispam_enabled) {
Expand Down
80 changes: 44 additions & 36 deletions locales/_pot/main.pot
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ msgid ""
msgstr ""
"Project-Id-Version: Dotclear 2 contactMe module\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2020-06-06 13:25+0200\n"
"POT-Creation-Date: 2020-09-17 11:18+0200\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
Expand All @@ -18,8 +18,8 @@ msgstr ""

#: ../git-plugins/contactMe/__html_tpl_dummy.php:4
#: ../git-plugins/contactMe/_public.php:18
#: ../git-plugins/contactMe/index.php:165
#: ../git-plugins/contactMe/index.php:169
#: ../git-plugins/contactMe/index.php:172
#: ../git-plugins/contactMe/index.php:176
msgid "Message"
msgstr ""

Expand All @@ -41,12 +41,12 @@ msgstr ""
#: ../git-plugins/contactMe/_admin.php:56
#: ../git-plugins/contactMe/_admin.php:65
#: ../git-plugins/contactMe/_public.php:39
#: ../git-plugins/contactMe/_public.php:297
#: ../git-plugins/contactMe/_public.php:304
#: ../git-plugins/contactMe/_widgets.php:23
#: ../git-plugins/contactMe/_widgets.php:25
#: ../git-plugins/contactMe/index.php:28
#: ../git-plugins/contactMe/index.php:110
#: ../git-plugins/contactMe/index.php:132
#: ../git-plugins/contactMe/index.php:29
#: ../git-plugins/contactMe/index.php:113
#: ../git-plugins/contactMe/index.php:135
msgid "Contact me"
msgstr ""

Expand Down Expand Up @@ -78,29 +78,29 @@ msgstr ""
msgid "Message seems to be a spam."
msgstr ""

#: ../git-plugins/contactMe/_public.php:163
#: ../git-plugins/contactMe/_public.php:170
msgid ""
"Hi there!\n"
"\n"
"You received a message from your blog's contact page."
msgstr ""

#: ../git-plugins/contactMe/_public.php:165
#: ../git-plugins/contactMe/_public.php:172
#, php-format
msgid "Blog: %s"
msgstr ""

#: ../git-plugins/contactMe/_public.php:166
#: ../git-plugins/contactMe/_public.php:173
#, php-format
msgid "Message from: %s <%s>"
msgstr ""

#: ../git-plugins/contactMe/_public.php:167
#: ../git-plugins/contactMe/_public.php:174
#, php-format
msgid "Website: %s"
msgstr ""

#: ../git-plugins/contactMe/_public.php:168
#: ../git-plugins/contactMe/_public.php:175
msgid "Message:"
msgstr ""

Expand All @@ -116,106 +116,114 @@ msgstr ""
msgid "Link title:"
msgstr ""

#: ../git-plugins/contactMe/index.php:32
#: ../git-plugins/contactMe/index.php:33
msgid "<p>You can use the following form to send me an e-mail.</p>"
msgstr ""

#: ../git-plugins/contactMe/index.php:36
#: ../git-plugins/contactMe/index.php:37
msgid "<p style=\"color:green\"><strong>Thank you for your message.</strong></p>"
msgstr ""

#: ../git-plugins/contactMe/index.php:40
#: ../git-plugins/contactMe/index.php:41
#, php-format
msgid "<p style=\"color:red\"><strong>An error occured:</strong> %s</p>"
msgstr ""

#: ../git-plugins/contactMe/index.php:55
#: ../git-plugins/contactMe/index.php:57
msgid "No recipients."
msgstr ""

#: ../git-plugins/contactMe/index.php:59
#: ../git-plugins/contactMe/index.php:61
msgid "No page title."
msgstr ""

#: ../git-plugins/contactMe/index.php:63
#: ../git-plugins/contactMe/index.php:65
msgid "No success message."
msgstr ""

#: ../git-plugins/contactMe/index.php:67
#: ../git-plugins/contactMe/index.php:69
msgid "No error message."
msgstr ""

#: ../git-plugins/contactMe/index.php:79
#: ../git-plugins/contactMe/index.php:81
#, php-format
msgid "%s is not a valid e-mail address."
msgstr ""

#: ../git-plugins/contactMe/index.php:100
#: ../git-plugins/contactMe/index.php:103
msgid "Setting have been successfully updated."
msgstr ""

#: ../git-plugins/contactMe/index.php:139
#: ../git-plugins/contactMe/index.php:142
msgid "Activate contactMe on blog"
msgstr ""

#: ../git-plugins/contactMe/index.php:140
#: ../git-plugins/contactMe/index.php:143
msgid "E-Mail settings"
msgstr ""

#: ../git-plugins/contactMe/index.php:141
#: ../git-plugins/contactMe/index.php:144
msgid "Comma separated recipients list:"
msgstr ""

#: ../git-plugins/contactMe/index.php:142
#: ../git-plugins/contactMe/index.php:145
msgid "Email"
msgstr ""

#: ../git-plugins/contactMe/index.php:143
#: ../git-plugins/contactMe/index.php:146
msgid "E-Mail subject prefix:"
msgstr ""

#: ../git-plugins/contactMe/index.php:145
#: ../git-plugins/contactMe/index.php:148
msgid "This will be prepend to e-mail subject"
msgstr ""

#: ../git-plugins/contactMe/index.php:149
msgid "SMTP account:"
msgstr ""

#: ../git-plugins/contactMe/index.php:151
msgid "This will be use as e-mail sender. Note that the sent e-mails will have a Reply-To filled with your correspondent e-mail."
msgstr ""

#: ../git-plugins/contactMe/index.php:158
msgid "Use comments spam filter"
msgstr ""

#: ../git-plugins/contactMe/index.php:155
#: ../git-plugins/contactMe/index.php:162
msgid "Presentation options"
msgstr ""

#: ../git-plugins/contactMe/index.php:157
#: ../git-plugins/contactMe/index.php:164
msgid "Page title:"
msgstr ""

#: ../git-plugins/contactMe/index.php:158
#: ../git-plugins/contactMe/index.php:165
msgid "Title"
msgstr ""

#: ../git-plugins/contactMe/index.php:160
#: ../git-plugins/contactMe/index.php:167
msgid "Form caption:"
msgstr ""

#: ../git-plugins/contactMe/index.php:164
#: ../git-plugins/contactMe/index.php:171
msgid "Confirmation message:"
msgstr ""

#: ../git-plugins/contactMe/index.php:168
#: ../git-plugins/contactMe/index.php:175
msgid "Error message:"
msgstr ""

#: ../git-plugins/contactMe/index.php:171
#: ../git-plugins/contactMe/index.php:178
#, php-format
msgid "\"%s\" is the error message."
msgstr ""

#: ../git-plugins/contactMe/index.php:173
#: ../git-plugins/contactMe/index.php:180
msgid "Save"
msgstr ""

#: ../git-plugins/contactMe/index.php:176
#: ../git-plugins/contactMe/index.php:183
#, php-format
msgid "Don't forget to add a <a href=\"%s\">“Contact Me” widget</a> linking to your contact page."
msgstr ""
8 changes: 7 additions & 1 deletion locales/en/main.po
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ msgid ""
msgstr ""
"Project-Id-Version: Dotclear 2 contactMe module\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2020-06-06 13:25+0200\n"
"POT-Creation-Date: 2020-09-17 11:18+0200\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
Expand Down Expand Up @@ -129,6 +129,12 @@ msgstr ""
msgid "This will be prepend to e-mail subject"
msgstr ""

msgid "SMTP account:"
msgstr ""

msgid "This will be use as e-mail sender. Note that the sent e-mails will have a Reply-To filled with your correspondent e-mail."
msgstr ""

msgid "Use comments spam filter"
msgstr ""

Expand Down
8 changes: 7 additions & 1 deletion locales/fr/main.po
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ msgid ""
msgstr ""
"Project-Id-Version: Dotclear 2 contactMe module\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2020-06-06 13:25+0200\n"
"POT-Creation-Date: 2020-09-17 11:18+0200\n"
"PO-Revision-Date: 2012-11-05 16:48+0100\n"
"Last-Translator: Franck Paul <carnet.franck.paul@gmail.com>\n"
"Language-Team: \n"
Expand Down Expand Up @@ -132,6 +132,12 @@ msgstr "Préfixe du sujet des messages :"
msgid "This will be prepend to e-mail subject"
msgstr "Ceci précédera le sujet du courrier électronique"

msgid "SMTP account (optional):"
msgstr "Compte SMTP à utiliser (optionnel) :"

msgid "This will be use as e-mail sender. Note that the sent e-mails will have a Reply-To filled with your correspondent e-mail."
msgstr "Ce compte sera utilisé comme émetteur du mail. Notez que les courriers électroniques envoyés contiendront l'adresse email de réponse fournie par votre correspondent·e."

msgid "Use comments spam filter"
msgstr "Utiliser le filtre de spam des commentaires"

Expand Down

0 comments on commit 7b224f9

Please sign in to comment.