Welcome, Guest
Username Password: Remember me

Ho to Send Dynamic email to the user
(1 viewing) (1) Guest
  • Page:
  • 1

TOPIC: Ho to Send Dynamic email to the user

Ho to Send Dynamic email to the user 1 year, 6 months ago #1

  • ashishb01
  • ( User )
  • OFFLINE
  • Junior Boarder
  • Posts: 22
  • Karma: 0
Hi,
I am using a DB Query Memeber email field to retrieve and display the user email in the submission form. My question is:

How i can use this Memeber email field to send the mail to the user. When I use write-Email field, I need to put the actual email address. is there any way I can use this field in the To box dynamically

Ashish

Re: How to Send Dynamic email to the user 1 year, 6 months ago #2

  • ashishb01
  • ( User )
  • OFFLINE
  • Junior Boarder
  • Posts: 22
  • Karma: 0
Hi Folks,
See, this amazing product needs even better support. Unfortunately I have made as many as 8 posts and have got a reply for only 1 .
Please answer this issue. Whether I can use jsebold-cck or not depends entirely on this functionality.

Thanks
Ashish

Re: How to Send Dynamic email to the user 1 year, 6 months ago #3

  • webfacsimon
  • ( Moderator )
  • OFFLINE
  • Moderator
  • Posts: 661
  • Karma: 32
Hi ashishb01,

First off, as this is a community, please be patient... People do not spend all day every day on these forumns waiting to answer questions, people have things to do and will respond if and when they can.

In your email sending data field, you have the option to specify a data field as a value for the TO part of the email, so if the field you are using as the email address is called member_email for example, try adding that in the area that says TO (field) and see if that helps.

As long as the field you are using to retrieve the users email address is the same as you specify in the TO field and as long as the data field is published in your form type, then there should be no issue sending the email to that address.
WAS I HELPFUL? DID I SAVE YOUR ASS? PLEASE CONSIDER DONATING SOMETHING SMALL

For jSeblod & SEBLOD tips & tricks visit www.onestuckpixel.com/

Re: How to Send Dynamic email to the user 1 year, 6 months ago #4

  • ashishb01
  • ( User )
  • OFFLINE
  • Junior Boarder
  • Posts: 22
  • Karma: 0
Thank you webfacsimon,

But if I am using a simple query or a free php code, the field is not displayed in the Site form.
Therefore if I put the field name in the write email field, it is not sending any email since the field does not have any value in the Site form.

Am I doing it right? Thanks for your reply again.

Ashish

Re: How to Send Dynamic email to the user 1 year, 6 months ago #5

  • ashishb01
  • ( User )
  • OFFLINE
  • Junior Boarder
  • Posts: 22
  • Karma: 0
Ok,
Here is how I did it.
Simply added a php free code field, retrieved the email of the user using .getUser() function, and sent the mail using Jmailer function. Worked for me

Re: How to Send Dynamic email to the user 1 year, 6 months ago #6

  • ashishb01
  • ( User )
  • OFFLINE
  • Junior Boarder
  • Posts: 22
  • Karma: 0
Ok,
Here is how I did it.
Simply added a php free code field, retrieved the email of the user using .getUser() function, and sent the mail using Jmailer function. Worked for me

Re: How to Send Dynamic email to the user 1 year, 1 month ago #7

  • mgm
  • ( User )
  • OFFLINE
  • Expert Boarder
  • Posts: 84
  • Karma: 1
Can you write more detail about send email? I need to do this, but don't understand about send email. Free Code I can use.

Re: How to Send Dynamic email to the user 1 year, 1 month ago #8

  • webfacsimon
  • ( Moderator )
  • OFFLINE
  • Moderator
  • Posts: 661
  • Karma: 32
Hi ashishb01,

Glad to hear you had it sorted, but for the benefit of the community it would be much appreciated if you could give a little back and post an example of the code you used (?)

That would be awesome of you,
Simon
WAS I HELPFUL? DID I SAVE YOUR ASS? PLEASE CONSIDER DONATING SOMETHING SMALL

For jSeblod & SEBLOD tips & tricks visit www.onestuckpixel.com/

Re: How to Send Dynamic email to the user 1 year, 1 month ago #9

  • ashishb01
  • ( User )
  • OFFLINE
  • Junior Boarder
  • Posts: 22
  • Karma: 0
I would be glad to help. But I am not sure if this is the best solution. I am using it as a workaround to achieve the objective but will be glad if jSebold comes up with a concrete solution for sending mails (much like chronoforms). Here is what I did:

I am using the Free Code PHP field in my content type (form and content panel) and calling the standard Joomla function (JMailer) to send the mail. Here is the code that I put in the php field:

//Fetching the user name and email to address the mail
$user = &JFactory::getUser();
$user_mail= $user->email;
$user_name= $user->name;

//This part is my html email message body
$email_message = '<br /> Dear '. $user->name.',<br /><br /> Thank you for submitting your document to Oracle Champions.<br /> We will now inspect your document to see if everything is complaint to our terms and then we will be able to publish it. Once Published, you will be able to view the document when you log in to Oracle Champions.<br /> Here are the steps to verify whether your article is published or not:<br /> <br /><ol>
<li> Log in to www.oraclechamps.com</li>
<li> Upon Log in, you will be directed to Your profile Page. </li>
<li> On your Profile page, check for the Section My Documentations</li>
<li> Your last 3 accepted documents will show there. Click on the "Show All" button to view all your articles.</li>
</ol> <br /> If accepted, you will be paid $1 per article (Your first article will NOT be paid as this will be considered as a registration charge for Intended serious candidates only). Thereafter, every month-end, we process the payments and send it to your Paypal Account.<br /> <br /> Thanks & Regards<br /> Administrator<br /> Oracle Champions
';

//Here I shoot the email using the JMailer Function
$mailer =& JFactory::getMailer();
$config =& JFactory::getConfig();
$sender = array($config->getValue( 'config.mailfrom' ),$config->getValue( 'config.fromname' ) );
$mailer->setSender($sender);
$mailer->addRecipient($user_mail);
$mailer->addBCC(' This e-mail address is being protected from spambots. You need JavaScript enabled to view it. ');

$mailer->setSubject('New Document Received');
$mailer->isHTML(true);
$mailer->setBody($email_message);
$send =& $mailer->Send();
if ( $send !== true ) {
echo 'Error sending email: ' . $send->message;
}
else echo 'Mail sent to '.$user_mail;

Hope this helps as a workaround. I repeat, it would be great to have email functionality (to be best to the registered user) as an out of the box solution


ashishb01
Last Edit: 1 year, 1 month ago by ashishb01.
The following user(s) said Thank You: webfacsimon

Re: How to Send Dynamic email to the user 1 year, 1 month ago #10

  • webfacsimon
  • ( Moderator )
  • OFFLINE
  • Moderator
  • Posts: 661
  • Karma: 32
Hello ashishb01 ,

Great stuff, and thanks for sharing! The code works like a charm, the ONLY issue I find when using the free code field is that you actually have no way of determining if the article / content type was successfully submitted. Even if there was a DB error our email would still be sent. That being said though, I like how you've utilized all Joomla's core functions / methods to get values and not simply used the php mailer function, nice work.

You could go one step further and replace your echoed success/failure messages with native joomla messages / notices using the enqueueMessage() function.

Thanks a million for sharing!

Simon
WAS I HELPFUL? DID I SAVE YOUR ASS? PLEASE CONSIDER DONATING SOMETHING SMALL

For jSeblod & SEBLOD tips & tricks visit www.onestuckpixel.com/
The following user(s) said Thank You: ashishb01

Re: How to Send Dynamic email to the user 1 year, 1 month ago #11

  • ashishb01
  • ( User )
  • OFFLINE
  • Junior Boarder
  • Posts: 22
  • Karma: 0
Thanks for your appreciation,

As I said it is a workaround and will have limitations. Thanks again for your suggestion on the error message. Actually I am not good at coding and whatever I did, I had to explore it hard. But I will surely incorporate your suggestion for the error as it is more robust.

Regards
ashishb01

Re: How to Send Dynamic email to the user 1 year, 1 month ago #12

  • mgm
  • ( User )
  • OFFLINE
  • Expert Boarder
  • Posts: 84
  • Karma: 1
Yesterday I read Joomla documentation a lot and found the best decision is Joomla's plugin for onAfterContentSave event. There is we have article (and all it's field) stored in DB and flag of submit/edit.

Re: How to Send Dynamic email to the user 1 year, 1 month ago #13

  • mgm
  • ( User )
  • OFFLINE
  • Expert Boarder
  • Posts: 84
  • Karma: 1
Yes, now I wrote plugin. It's work!!!
But more simple then post #9 because of use SendMail() Joomla's function

 
jimport( 'joomla.utilities.utility' );
 
function onAfterContentSave( &$article, $isNew ){
global $mainframe;
 
$user = & JFactory::getUser();
$komu = $user->email; // user email
$tema = 'title of letter';
$otkuda = 'admin@mysitename'; // email of sender
$fotkogo = 'my site name';
$mode = 0; // text (1 - html)
$body = 'any text - body of letter';
 
JUtility::SendMail($otkuda, $otkogo, $komu, $tema, $body, $mode);
return true;
}


And here you can get any data from article by &$article->joomla_field_name
If you want to get jSeblod field value you have to parse field &$article->introtext
Last Edit: 1 year, 1 month ago by mgm.

Re: How to Send Dynamic email to the user 1 year, 1 month ago #14

  • unleash.it
  • ( User )
  • OFFLINE
  • Platinum Boarder
  • Posts: 480
  • Karma: 23
Just curious if I missed something here... Can't you just insert a Joomla user field in your content type and then have the email send it to the field name (without extra PHP)?

Or if that doesn't work... couldn't you just call the user in a php field and use an email field to send to that php field... without making a new email function?

Re: How to Send Dynamic email to the user 1 year, 1 month ago #15

  • spunwasi
  • ( User )
  • OFFLINE
  • Expert Boarder
  • Posts: 88
  • Karma: 0
Hey Ashishb01,


Thanks a lot, not needed now but certainly going to be a life saver later.

Best Regards,
Stephen
  • Page:
  • 1
Time to create page: 0.38 seconds