Jump to content

send email on database insert trigger


ahmadmasoood

Recommended Posts

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
Share on other sites

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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.