Welcome, Guest
Username: Password: Remember me
  • Page:
  • 1
  • 2

TOPIC: send a mail after saving !!

send a mail after saving !! 20 Feb 2013 14:59 #6821

Hi,

I want to send a mail after save the data! (i use JTable)
But i do not find the function save!!
It should be in the controller isn't?
but i do not find !

Where can i put these lines of code ???

thanks

PS: I tried change of Category to place in development but i have been not able !
Last Edit: 20 Feb 2013 15:00 by robertocook.
The administrator has disabled public write access.

Re: send a mail after saving !! 20 Feb 2013 20:27 #6822

  • VeCrea
  • VeCrea's Avatar
  • Offline
  • Platinum Member
  • Absolute JCook fan
  • Posts: 473
  • Thank you received: 100
  • Karma: 30
I have set DB automatisms to Table in the builder's config tab.
Then, I use the native joomla mail function in the administrator/components/name_of_my_component/tables/name_of_table.php
At the end of this file, here's my code
// Init mail send
$mail =& JFactory::getMailer();
$config =& JFactory::getConfig();
$mail->isHTML(true);
$mail->addRecipient('mail@mail.com');
$body = "Here is my text";
$mailSubject = "This is my subject"
$mail->setBody($body);
$mail->setSubject($mailSubject);
$mail->Encoding = 'base64';

if ($mail->Send()) {
  echo "Mail sent successfully.";
  $app = JFactory::getApplication();
  $app->enqueueMessage('Mail sent');
} else {
  echo "An error occurred.  Mail was not sent.";
}
Last Edit: 20 Feb 2013 20:28 by VeCrea.
The administrator has disabled public write access.
The following user(s) said Thank You: admin, edwardcox, JoomGuy

Re: send a mail after saving !! 21 Feb 2013 09:32 #6825

thanks !
The administrator has disabled public write access.

Re: send a mail after saving !! 22 Feb 2013 15:07 #6832

  • JoomGuy
  • JoomGuy's Avatar
  • Offline
  • Moderator
  • Joomla Enthusiast, Lover of Cooking
  • Posts: 1115
  • Thank you received: 195
  • Karma: 64
@VeCrea Thanks for the share!

I'm not 100% sure whether or not it would make any difference but, I would tend to do exactly the same but create a private function in the model, called from the controller that runs whenever the the save returns true (1).

Any thoughts on how best to approach this welcome fellow cooks!

Thanks again VeCrea,

Gez
Need help with your Cook/Joomla Project? . PM me to find out what I can help with. NO time wasters please!!!
The administrator has disabled public write access.

Re: send a mail after saving !! 22 Feb 2013 16:08 #6836

  • VeCrea
  • VeCrea's Avatar
  • Offline
  • Platinum Member
  • Absolute JCook fan
  • Posts: 473
  • Thank you received: 100
  • Karma: 30
Could it be a question of where DB Automatisms are placed ? In my example, option is set as Table, and not Model. Not sure about that you know, just my 2 cents
The administrator has disabled public write access.

Re: send a mail after saving !! 24 May 2013 14:37 #7224

  • pinochet
  • pinochet's Avatar
  • Offline
  • Senior Member
  • Posts: 47
  • Karma: 0
I am new in the cook, have a two questions:
1= to paste this code in that file, send anything new added to this table to the post?
2= I will have to create a model for sending html mail?
dread to consider my queries, Thank you in advance
The administrator has disabled public write access.

Re: send a mail after saving !! 24 May 2013 20:22 #7228

  • VeCrea
  • VeCrea's Avatar
  • Offline
  • Platinum Member
  • Absolute JCook fan
  • Posts: 473
  • Thank you received: 100
  • Karma: 30
1. It sends an email each time you save
2. No. (what's a model to you, just to be sure?)
The administrator has disabled public write access.

Re: send a mail after saving !! 27 May 2013 13:48 #7234

  • pinochet
  • pinochet's Avatar
  • Offline
  • Senior Member
  • Posts: 47
  • Karma: 0
what decearia mail, would be part of the information (or complete) that is sending the db table wing, you think it's possible?
The administrator has disabled public write access.

Re: send a mail after saving !! 27 May 2013 17:01 #7235

  • VeCrea
  • VeCrea's Avatar
  • Offline
  • Platinum Member
  • Absolute JCook fan
  • Posts: 473
  • Thank you received: 100
  • Karma: 30
Don't understand you man ;)
The administrator has disabled public write access.

Re: send a mail after saving !! 03 Jun 2013 11:53 #7280

  • admin
  • admin's Avatar
  • Offline
  • Administrator
  • Chef
  • Posts: 3711
  • Thank you received: 987
  • Karma: 140
Yes of course it is possible.

Place your code in the controller after the save() execution.
Check if the item is new and call the JMailer.

I am working to find the best way to send mails with a template view from Cook, but this is still in dev.

For the moment, use the Joomla native functions to do it.
Coding is now a piece of cake
The administrator has disabled public write access.

Re: send a mail after saving !! 05 Jun 2013 14:56 #7352

  • pinochet
  • pinochet's Avatar
  • Offline
  • Senior Member
  • Posts: 47
  • Karma: 0
would be so kind as to tell me the driver path to paste the code, plus as you think you could take the information that will be sent to DB to send mail? please help me
The administrator has disabled public write access.

Re: send a mail after saving !! 05 Jun 2013 16:32 #7358

  • admin
  • admin's Avatar
  • Offline
  • Administrator
  • Chef
  • Posts: 3711
  • Thank you received: 987
  • Karma: 140
First, to catch your datas, you must be able to know that when your develop with cook. It is fundamental stuff.
Look in the view files, there is a lot of model calls there.

Instance the model with the correct id of your item. then get the datas.

About JMail, follows the documentation :
api.joomla.org/Joomla-Platform/Mail/JMail.html
Coding is now a piece of cake
The administrator has disabled public write access.

Re: send a mail after saving !! 05 Jun 2013 16:39 #7359

  • admin
  • admin's Avatar
  • Offline
  • Administrator
  • Chef
  • Posts: 3711
  • Thank you received: 987
  • Karma: 140
I prefer not to give you a ready to paste solution because :
- I answer fast and by memory
- It is more satisfaction to find by ourself
- You learn it, and you can then teach afterwards, or anser to the others.

Most of the time it is not good to copy/paste, because it is only to explain a concept and can be missing the security part, and/or create collateral issues.

Always better to dig by yourself, you will be able to reproduce more and more when the concept is understood.
I am not saying this particulary to you.
Always good to remember, that we are here to share our secrets and also to sustain each other in the learning process.

I recently asked for help too, on this forum.
Coding is now a piece of cake
The administrator has disabled public write access.
The following user(s) said Thank You: pinochet

Re: send a mail after saving !! 05 Jun 2013 17:23 #7364

  • pinochet
  • pinochet's Avatar
  • Offline
  • Senior Member
  • Posts: 47
  • Karma: 0
Thank you for what you have said is all I need, thanks for taking the time to answer ....
The administrator has disabled public write access.

send a mail after saving !! 03 Jul 2013 23:49 #7846

  • pinochet
  • pinochet's Avatar
  • Offline
  • Senior Member
  • Posts: 47
  • Karma: 0
I've tested and works through sending emails, which no logo and I've tried a thousand ways is to capture the data to send.
pordría someone give me a clue how to do it please
The administrator has disabled public write access.
  • Page:
  • 1
  • 2
Time to create page: 0.086 seconds

Get Started