I’m running MariaDB SQL server on Debian Linux, I have phpMyAdmin installed. SSMTP is installed and configured so I can send emails from the command line.
I have a simple table, called team_members, and every time a new team member is added to the table, a new row with unique ID is created, I would like to know how to send what has been added to the table as an email.
+------------+--------------+------+-----+---------------------+----------------+
| Field | Type | Null | Key | Default | Extra |
+------------+--------------+------+-----+---------------------+----------------+
| id | int(11) | NO | PRI | NULL | auto_increment |
| nickname | varchar(255) | NO | UNI | NULL | |
| first_name | varchar(255) | NO | | NULL | |
| last_name | varchar(255) | NO | | NULL | |
| email | varchar(255) | NO | UNI | NULL | |
| timestamp | timestamp | NO | | current_timestamp() | |
+------------+--------------+------+-----+---------------------+----------------+
I understand that this is possible using a trigger, but I don’t really understand how it works.
Could anyone possibly give me an example of how to achieve this.
This table is not going to be updated very often, maybe once a month, so its not going to cause lots of unwanted emails.
2
Answers
I couldn't find away to do this so I used PHPMailer to email the content of the input form instead. Its not exactly 100% what I wanted to it works.
For security reasons, you cannot invoke any actions outside of MySQL from within MySQL. So, no, you cannot send an email.
On the other hand, your application that does the
INSERT
could do some form of sendmail.