-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathREADME
45 lines (25 loc) · 1.55 KB
/
README
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
Function to send mail by smtp in 9.3+
Edited & Tested for Postgresql 16.0
======================================
This PostgreSQL extension implements a functions to send mail and attach by smtp using plpython
IMPORTANT: There're bugs in the existing version, please contact to me.
This extentsion in only executable by admid user, because use untrusted language plpython
Building and install
--------
Install postgresql-plpython:sudo apt-get install postgresql-plpython-9.x (where x >=3)
Run make install
In postgresql execute: CREATE EXTENSION plpython3u;
create extension pgsmtp;
Example
-------
#insert data(user, smtpserver,port,password) about the sender user un into table pgsmtp.user_smtp_data, is required to send mail
INSERT INTO pgsmtp.user_smtp_data VALUES ('[email protected]','smtp.gmail.com',587,'mypass')
#sending mail pgsmtp.pg_smtp_mail(sender, receiver, cc,topic,text) with cc
select pgsmtp.pg_smtp_mail('[email protected]','[email protected]',array['[email protected]','[email protected]'],'Test mail','Mail from postgres using pgsmtp :D');
#sending mail pgsmtp.pg_smtp_mail(sender, receiver, cc,topic,text) without cc
select pgsmtp.pg_smtp_mail('[email protected]','[email protected]',array[''],'Test mail','Mail from postgres using pgsmtp :D');
#sending mail pgsmtp.pg_smtp_mail_attach(sender, receiver, cc,topic,text,attach) with attach
select pgsmtp.pg_smtp_mail_attach('[email protected]','[email protected]',array[''],'Test mail','Mail from postgres using pgsmtp :D',array['/tmp/adjunto.txt']);
--
Anthony R. Sotolongo leon