ahmadmasoood Posted November 30, 2010 Share Posted November 30, 2010 can anyone please help me that i m a new user of PHP and linux so please tell me how i can send an email when mySQL insert trigger have been generated. the scenario is like this, that when new value insert in a table (client_Table), then insert trigger is generated and the functionality of that trigger is that it gets the last inserted row Primary ID (suppose the value is '111') and get the specific audio file (with the name of "111") from specific location in Linux path (/var/lib/audio/"TablePrimaryID".wav) and send Email with audio file attachment and primary ID, to any specific Mail address. (with the help of gmail SMTP). Link to comment https://forums.phpfreaks.com/topic/220285-send-email-on-database-insert-trigger/ Share on other sites More sharing options...
The Little Guy Posted November 30, 2010 Share Posted November 30, 2010 I would do something like if(mysql_query("INSERT INTO tbl (val1) VALUES ('my value 1')");{ $id = mysql_insert_id(); mail('[email protected]', 'Subject', 'Welcome to my site '.$id.'!'); } Link to comment https://forums.phpfreaks.com/topic/220285-send-email-on-database-insert-trigger/#findComment-1141521 Share on other sites More sharing options...
AbraCadaver Posted November 30, 2010 Share Posted November 30, 2010 can anyone please help me that i m a new user of PHP and linux so please tell me how i can send an email when mySQL insert trigger have been generated. the scenario is like this, that when new value insert in a table (client_Table), then insert trigger is generated and the functionality of that trigger is that it gets the last inserted row Primary ID (suppose the value is '111') and get the specific audio file (with the name of "111") from specific location in Linux path (/var/lib/audio/"TablePrimaryID".wav) and send Email with audio file attachment and primary ID, to any specific Mail address. (with the help of gmail SMTP). Why do you need a trigger? Untested example that leaves some work for you: //$link = connect //select db mysql_query("INSERT INTO table_name (field1, field2) VALUES ('something', 'something else')"); $id = mysql_insert_id($link); $file = "/var/lib/audio/$id.wav"; // use a mail class that makes sending attachments easy, maybe switfmailer? Link to comment https://forums.phpfreaks.com/topic/220285-send-email-on-database-insert-trigger/#findComment-1141523 Share on other sites More sharing options...
ahmadmasoood Posted December 1, 2010 Author Share Posted December 1, 2010 i want to make a something like SendEmail BATCH file and i want run it from perl code. plz tell me how in can make a PHP batch file for sending email and i can run it in CentOS CLI mode. Link to comment https://forums.phpfreaks.com/topic/220285-send-email-on-database-insert-trigger/#findComment-1141775 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.