Send email from MySQL

Posted by admin on Jun 7, 2009 in Database |

Dump the mail message into the pickup directory and it should be sent.

select “To: email@address.somewhere”,”From: triggers@mysql”,”Subject: Trigger”,””,”Hello World”
into outfile “/inetpub/mailroot/pickup/mail.eml”
fields terminated by ‘\r\n’;

DELIMITER |
CREATE TRIGGER sometable_after_update AFTER UPDATE ON some_table FOR EACH ROW BEGIN
SELECT  concat(“To: “,NEW.mail),
“From: triggers@mysql”,
concat(“Subject: “,NEW.subject),
“”,
NEW.body
INTO OUTFILE “/inetpub/mailroot/pickup/mail.eml”
FIELDS TERMINATED by ‘\r\n’;
END;|
DELIMITER ;

1 Comment

Leave a Reply

XHTML: You can use these tags:' <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

Copyright © 2008-2018 Brinsmead Data Services All rights reserved.