Support > cpg1.5 email
Contact from option - copy to self
twoclones:
On the Contact Form, how can I have an option for "send yourself a copy" ? There doesn't appear to be an option for this in the Config.
Αndré:
Such an option doesn't exist, as such a feature currently doesn't exist. However, this could be added as a mod. I've currently no time to create this mod immediately. Please reply to this thread, so I can highlight it in my inbox and will create the mod later.
IMHO that feature should go to core.
twoclones:
Thank you. It would be great to have this option :)
gmc:
I think that is a great idea too...
Αndré,
Attached is a zipped patch file based on SVN 8660 that implements this feature for your review...
As there is a change (one line addition) to language file - I assumed you would want a hidden config option in 1.5.x... and build into 1.6.
Summary:
Insert a record into cpg_config with name 'contact_form_cc_sender_field' and value '1' to enable support
If this option is set... AND (either a registered user OR guest and displaying email field to guest)
- then an option will be displayed on contact.php to allow user to select 'Send me a copy of contact email'...
(otherwise we have no way to get an email to cc to...)
On submit, if a valid email is provided (registered user may not have email... guest email may be optional), and new config option is set
- a CC will be added to the email using the sender email provided (in form or from registered user data).
Updated:
contact.php: form additions and processing data on submit
include/mailer.inc.php: updated function cpg_mail to receive and process $cc_sender using the AddCC function of the cpg_PHPMailer class.
lang/english.php: add text for label on form for new field
gmc:
For those not familiar with or using SVN, the following changes were proposed:
Based on 1.5.26+...
In contact.php:
Find:
--- Code: --- $email_address = $superCage->post->getEscaped('sender_email');
--- End code ---
INSERT after:
--- Code: --- $cc_sender = ($superCage->post->keyExists('cc_sender')) ? $superCage->post->getInt('cc_sender') : FALSE; //*GMC added support to CC sender
--- End code ---
Find **ALL OCCURRENCES** of : (there will be 4... only 3 are needed, but changing all 4 doesn't hurt... (the first case is caught by form processing)
--- Code: --- $sender_email = $CONFIG['gallery_admin_email'];
--- End code ---
INSERT after EACH:
--- Code: --- $cc_sender = FALSE; //*GMC no valid sender email - turn off CC if set
--- End code ---
Find:
--- Code: --- if (!cpg_mail($CONFIG['gallery_admin_email'], $subject, $html_message, 'text/html', $sender_name, $sender_email, $message)) {
--- End code ---
REPLACE with:
--- Code: ---+ if (!cpg_mail($CONFIG['gallery_admin_email'], $subject, $html_message, 'text/html', $sender_name, $sender_email, $message, $cc_sender)) { //*GMC added cc_sender as parm
--- End code ---
Find:
--- Code: --- <td class="tableb">
<span id="email_wrapper" class="{$highlightFieldCSS}">
<input type="text" class="textinput" name="sender_email" size="30" maxlength="200" value="{$email_address}" style="width:100%" />
</span>
</td>
<td class="tableb">
<span id="email_remark" style="display:{$email_remark_visibility}">{$lang_contact_php['email_field_mandatory']}</span>
</td>
</tr>
EOT;
}
--- End code ---
INSERT after:
--- Code: ---//*GMC added cc field based on ('hidden' for 1.5) config option 'contact_form_cc_sender_field' - and if we have an emailid (USER_ID or $CONFIG['contact_form_guest_email_field']
if ((USER_ID || $CONFIG['contact_form_guest_email_field'] != 0) && $CONFIG['contact_form_cc_sender_field']) {
print <<< EOT
<tr>
<td class="tableb" align="right">
{$lang_contact_php['cc_me']}
</td>
<td class="tableb">
<span id="cc_wrapper">
<input type="checkbox" class="checkbox" name="cc_sender" value="1" />
</span>
</td>
<td class="tableb">
</td>
</tr>
EOT;
}
//*GMC end modifications for cc field
--- End code ---
In include/mailer.inc.php:
Find:
--- Code: ---function cpg_mail($to, $subject, $msg_body = '', $type = 'text/plain', $sender_name = '', $sender_email = '', $msg_body_plaintext = '')
{
global $CONFIG, $lang_charset, $HTML_SUBST;
--- End code ---
REPLACE with:
--- Code: ---function cpg_mail($to, $subject, $msg_body = '', $type = 'text/plain', $sender_name = '', $sender_email = '', $msg_body_plaintext = '', $cc_sender = FALSE)
{
global $CONFIG, $lang_charset, $HTML_SUBST;
//*GMC Added $cc_sender as optional parm - FALSE by default - if TRUE, add sender_email as CC recipient.
//*GMC - used in contact.php if chosen by user and valid sender email provided.
--- End code ---
In include/mailer.inc.php:
Find:
--- Code: --- foreach ($to as $email) {
$mail->AddAddress($email);
}
--- End code ---
INSERT after:
--- Code: ---
if ($cc_sender) { //*GMC add CC to sender if requested
$mail->AddCC($sender_email);;
} //*GMC - end additions
--- End code ---
In lang/english.php: (or language file of your choice with appropriate translations...)
Find:
--- Code: ---$lang_contact_php['your_email'] = 'Your email address'; // cpg1.5
--- End code ---
INSERT after:
--- Code: ---$lang_contact_php['cc_me'] = 'Send me a copy of contact email'; // cpg1.5 //*GMC added support to cc sender
--- End code ---
Via phpMyAdmin or equivalent (substituting cpg table prefix for cpg_):
--- Code: ---INSERT INTO `cpg_config` (`name`, `value`) VALUES ('contact_form_cc_sender_field', '1');
--- End code ---
deleting the above name/value - or setting value to 0 disables the support.
and now you see why I used a patch file that makes the updates for me... :)
Navigation
[0] Message Index
[#] Next page
Go to full version