can anyone please help me that 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).
send email on database insert triger
Moderator: General Moderators
-
ahmadmasoood
- Forum Newbie
- Posts: 4
- Joined: Tue Nov 30, 2010 2:37 pm
- AbraCadaver
- DevNet Master
- Posts: 2572
- Joined: Mon Feb 24, 2003 10:12 am
- Location: The Republic of Texas
- Contact:
Re: send email on database insert triger
Why do you need a trigger? Untested example that leaves some work for you:
Code: Select all
//$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?mysql_function(): WARNING: This extension is deprecated as of PHP 5.5.0, and will be removed in the future. Instead, the MySQLi or PDO_MySQLextension should be used. See also MySQL: choosing an API guide and related FAQ for more information.
-
ahmadmasoood
- Forum Newbie
- Posts: 4
- Joined: Tue Nov 30, 2010 2:37 pm
Re: send email on database insert triger
basically i m inserting a data in mySQL from Perl code and then i want to execute the PHP Send Email code from perl file or want to make database insert trigger to send email.
plz tell me in easy way coz i m new user of PHP and Linux...
plz tell me in easy way coz i m new user of PHP and Linux...