How to email to a custom field

  • helpjd
  • Topic Author
  • Offline
  • New Member
  • New Member
More
13 years 2 months ago #8281 by helpjd
How to email to a custom field was created by helpjd
Can we send a notification email to a custom field?
I have a custom field called Honoree Email for a gift donation form. I added tag [JD_HONOREE_EMAIL] to Notification Emails field in the Messages tab of the Campaign, but it doesn't send email to that email address. Please tell me how I can send a thank you email to that email address?

Please Log in or Create an account to join the conversation.

More
13 years 1 month ago - 13 years 1 month ago #8288 by Tuan Pham Ngoc
Replied by Tuan Pham Ngoc on topic Re: How to email to a custom field
Hi

You will need to modify the code of the sendMail function in the file components/com_jdonation/helper.php . The code for sending notification email is from line 204 to line 208 :
Code:
if ($config->notification_emails == '') $notificationEmails = $fromEmail; else $notificationEmails = $config->notification_emails; $notificationEmails = str_replace(' ', '', $notificationEmails); $emails = explode(',', $notificationEmails); $subject = $config->admin_email_subject ; $body = $config->admin_email_body; $body = str_replace('[DONATION_DETAIL]', $emailContent, $body); foreach ($replaces as $key=>$value) { $key = strtoupper($key) ; $body = str_replace("[$key]", $value, $body) ; } for ($i = 0, $n = count($emails); $i < $n ; $i++) { $email = $emails[$i]; JUtility::sendMail($fromEmail, $fromName, $email, $subject, $body, 1); }

You will need to modify the code in that section to include the email you want . If the name of custom field is jd_honoree_email, I believe we can modify the above code alitle like that :
Code:
if ($config->notification_emails == '') $notificationEmails = $fromEmail; else $notificationEmails = $config->notification_emails; $notificationEmails = str_replace(' ', '', $notificationEmails); $emails = explode(',', $notificationEmails); $honoreeEmail = JRequest::getVar('jd_honoree_email'); //Get the email users entered in the form if ($honoreeEmail) { $emails[] = $honoreeEmail ; } $subject = $config->admin_email_subject ; $body = $config->admin_email_body; $body = str_replace('[DONATION_DETAIL]', $emailContent, $body); foreach ($replaces as $key=>$value) { $key = strtoupper($key) ; $body = str_replace("[$key]", $value, $body) ; } for ($i = 0, $n = count($emails); $i < $n ; $i++) { $email = $emails[$i]; JUtility::sendMail($fromEmail, $fromName, $email, $subject, $body, 1); }

Please note that code in bold section where I get the email users entered and add it to list of emails will receive notification .

Hope this help !

Regards,

Tuan
Last edit: 13 years 1 month ago by Tuan Pham Ngoc.

Please Log in or Create an account to join the conversation.

  • helpjd
  • Topic Author
  • Offline
  • New Member
  • New Member
More
13 years 1 month ago #8289 by helpjd
Replied by helpjd on topic Re: How to email to a custom field
Thanks for your quick response. I really appreciate the coding instructions. However, I have a couple questions:
1. I need to email the custom field email address for only one of the campaigns. Is the change to the code going to force all campaigns to send emails to the custom field email address?
2. I need the email sent to both the donor (the regular EMAIL field) and a separate email to the person they are donating in honor of (jd_honoree_email). Does the code change still send thank you email to

Please Log in or Create an account to join the conversation.

More
13 years 1 month ago #8290 by Tuan Pham Ngoc
Replied by Tuan Pham Ngoc on topic Re: How to email to a custom field

1. I need to email the custom field email address for only one of the campaigns. Is the change to the code going to force all campaigns to send emails to the custom field email address?


=> The above code will send email to all campaign !


2. I need the email sent to both the donor (the regular EMAIL field) and a separate email to the person they are donating in honor of (jd_honoree_email). Does the code change still send thank you email to

3. I thought the Notification Emails field on the Messages Tab was designed to add email notifications. What is the purpose of that field? If I add JD_HONOREE_EMAIL to the Notification Email in the Messages Tab, what does it do with that email address tag?


=> The purpose of Notification Emails is that it allows the extension to send notificaiton to the entered emails when someone donate for your site. However, you can only enter REAL EMAILS there, It doesn't support tag (JD_HONOREE_EMAIL) . The system could not sent email to JD_HONOREE_EMAIL because it is not an email !

Thanks,

Tuan

Please Log in or Create an account to join the conversation.

  • helpjd
  • Topic Author
  • Offline
  • New Member
  • New Member
More
13 years 1 month ago #8297 by helpjd
Replied by helpjd on topic Re: How to email to a custom field
Tuan,

Thank you for the clarifications. I need to send confirmation emails to the donor email address (EMAIL) and the honoree email addresses (JD_HONOREE_EMAIL) for only one of my campaigns (Gift donation campaign). What would be the best way to handle that?

Thank you so much for your assistance. I really appreciate your help.

Please Log in or Create an account to join the conversation.

More
13 years 1 month ago #8303 by Tuan Pham Ngoc
Replied by Tuan Pham Ngoc on topic Re: How to email to a custom field
If you know alitle php coding, base on my suggestion above, you can modify the code easily to meet your need . Do you know PHP ?

Please Log in or Create an account to join the conversation.

More
13 years 1 month ago - 13 years 1 month ago #8308 by learnjoom
Replied by learnjoom on topic Re: How to email to a custom field
I would also like to learn how to code for adding a custom email to the confirmation email list
Last edit: 13 years 1 month ago by learnjoom.

Please Log in or Create an account to join the conversation.

  • helpjd
  • Topic Author
  • Offline
  • New Member
  • New Member
More
13 years 1 month ago #8315 by helpjd
Replied by helpjd on topic Re: How to email to a custom field
A little - but with your help I would like to implement the change.
Can you help me with the code change to send a confirmation email to the donor (email) and jd_honoree_email.

Thank you

Please Log in or Create an account to join the conversation.

  • helpjd
  • Topic Author
  • Offline
  • New Member
  • New Member
More
13 years 1 month ago #8346 by helpjd
Replied by helpjd on topic Re: How to email to a custom field
Hi Tuan,

You outlined the change in code for an additional notification email address. Is the code change the same for a confirmation email that is being sent out to the second email address as well or should the change get implemented elsewhere.
Thank you for your help.


if ($config->notification_emails == '')
$notificationEmails = $fromEmail;
else
$notificationEmails = $config->notification_emails;
$notificationEmails = str_replace(' ', '', $notificationEmails);
$emails = explode(',', $notificationEmails);
$honoreeEmail = JRequest::getVar('jd_honoree_email'); //Get the email users entered in the form
if ($honoreeEmail) {
$emails[] = $honoreeEmail ;
}$subject = $config->admin_email_subject ;
$body = $config->admin_email_body;
$body = str_replace('[DONATION_DETAIL]', $emailContent, $body);
foreach ($replaces as $key=>$value) {
$key = strtoupper($key) ;
$body = str_replace("[$key]", $value, $body) ;
}
for ($i = 0, $n = count($emails); $i < $n ; $i++) {
$email = $emails[$i];
JUtility::sendMail($fromEmail, $fromName, $email, $subject, $body, 1);
}

Please Log in or Create an account to join the conversation.

More
13 years 1 month ago #8356 by Tuan Pham Ngoc
Replied by Tuan Pham Ngoc on topic Re: How to email to a custom field
Hi

Today I am alitle busy and could not work on the code for you. I will work on it on tomorrow and send you the modified file. Could you please confirm you are using latest version (2.8.0) of the extension ? Or let me know the version you are using ?

Thanks,

Tuan

Please Log in or Create an account to join the conversation.

Moderators: Mr. DamDũng Nguyễn Việt