Send email containing data just inserted in the table

Discussions related to customizing hooks. Hooks are documented at http://bigprof.com/appgini/help/advanced-topics/hooks/
Post Reply
facos79
Veteran Member
Posts: 115
Joined: 2014-10-29 12:31

Send email containing data just inserted in the table

Post by facos79 » 2017-10-31 14:09

Hi everyone, I'm crazy. I can not solve the problem.
I have a table where the assistance intervals are entered. Once you've entered the line, I would like to have it sent to my final customer an email containing the summary of what's included in the table or a link that points to the table's visible page without registration.
How do I do it?
Below the code. What am I doing wrong ?



Code: Select all

	function Interventi_after_insert($data, $memberInfo, &$args){


$EmailI=sqlValue("SELECT `Email` FROM `Clienti` WHERE `id`=".$data['Cliente']);
$dc=sqlValue("SELECT `Durata_ore` FROM `Contratti` WHERE `id`=".$data['Durata_contratto']);

$Clientem=sqlValue("SELECT `Ragione_Sociale` FROM `Clienti` WHERE `id`=".$data['Ragione_Sociale`']);
$Datam=sqlValue("SELECT `Data` FROM `Interventi` WHERE `id`=".$data['Cliente']);
$Descrizione_interventom=sqlValue("SELECT `Descrizione_intervento` FROM `Interventi` WHERE `id`=".$data['Cliente']);
$Durata_interventom=sqlValue("SELECT `Durata_intervento` FROM `Interventi` WHERE `id`=".$data['Cliente']);

$sum=sqlValue("SELECT sum(`Durata_intervento`) FROM `Interventi` WHERE `Cliente`=".$data['Cliente']);
		
$rr=$dc-$sum;
sql("UPDATE `Interventi` SET `Ore_rimanenti`='".$rr."' WHERE `id`=".$data['selectedID'],$eo);



	foreach($data as $field => $value){
		$messageData .= "$field: $value \n";
	}


@mail(
		// mail recipient
		"$EmailI",
		
		// subject
		"Intervento eseguito - Consulente Tecnico Informatico",
		
		// message
		" Ho eseguito un nuovo intervento, puoi visualizzare il riepilogo ".

	
"Cliente: $Clientem \n" .
"Data: $Datam \n" .
"Intervento: $Descrizione_interventom \n " .
"OreContratto: $dc \n" .
"Durata: $Durata_interventom \n" .
"Ore Rimanenti: $Ore_rimanenti \n" ,


		
		// sender address
		"From: [email protected]"


		
	);



		return TRUE;
	}

Abeer
Posts: 18
Joined: 2017-03-12 09:19

Re: Send email containing data just inserted in the table

Post by Abeer » 2017-11-14 07:57

have you tried to send email from your admin area and made sure that email configurations and sending email is working fine?

miteshpc
Posts: 6
Joined: 2016-04-04 20:19

Re: Send email containing data just inserted in the table

Post by miteshpc » 2017-11-26 20:07

How to test if the sending of email is working fine after setting the new SMTP facility in admin area? A hook on insert sounds the right way but when it doesn't send via the SMTP server defined, then what to do?

Bertv
Veteran Member
Posts: 65
Joined: 2013-12-11 15:59

Re: Send email containing data just inserted in the table

Post by Bertv » 2017-12-01 09:45

For testing your SMTP settings you can use a dummy smtp server like this one: https://github.com/rnwood/smtp4dev
It works great.
Bert
I am using Appgini 5.75

facos79
Veteran Member
Posts: 115
Joined: 2014-10-29 12:31

Re: Send email containing data just inserted in the table

Post by facos79 » 2017-12-07 18:12

Vi ringrazio....

Post Reply