Skip to content
No description, website, or topics provided.
PLpgSQL Makefile
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.


Function to send mail by smtp in 9.3+
#No tested in 9.2-

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 plpythonu;
              create extension pgsmtp;

#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 ('','',587,'mypass')

#sending mail pgsmtp.pg_smtp_mail(sender, receiver, cc,topic,text) with cc

select pgsmtp.pg_smtp_mail('','',array['',''],'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('','',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('','',array[''],'Test mail','Mail from postgres using pgsmtp :D',array['/tmp/adjunto.txt']);

Anthony R. Sotolongo leon

You can’t perform that action at this time.