CREATE OR REPLACE PROCEDURE SEND_MAIL_TCP (errbuf OUT VARCHAR2,
retcode OUT VARCHAR2
) IS
msg_from VARCHAR2(200) := 'sekhar.byna@gmail.com';
msg_to VARCHAR2(200) :=info@ebiztechnics.com' ;
msg_subject VARCHAR2(200) := 'Oracle Apps Support/training' ;
msg_text VARCHAR2(200) := 'this is text mail' ;
c UTL_TCP.CONNECTION;
rc INTEGER;
BEGIN
c := UTL_TCP.OPEN_CONNECTION('192.168.0.1', 80); -- open the SMTP port 25 on local machine
rc := UTL_TCP.WRITE_LINE(c, '192.168.0.1');
rc := UTL_TCP.WRITE_LINE(c, 'MAIL FROM: '||msg_from);
rc := UTL_TCP.WRITE_LINE(c, 'RCPT TO: '||msg_to);
rc := UTL_TCP.WRITE_LINE(c, 'DATA'); -- Start message body
rc := UTL_TCP.WRITE_LINE(c, 'Subject: '||msg_subject);
rc := UTL_TCP.WRITE_LINE(c, '');
rc := UTL_TCP.WRITE_LINE(c, msg_text);
rc := UTL_TCP.WRITE_LINE(c, '.');
rc := UTL_TCP.WRITE_LINE(c, 'QUIT');
UTL_TCP.CLOSE_CONNECTION(c);
EXCEPTION
WHEN OTHERS THEN
RAISE_APPLICATION_ERROR(-20000, 'Unable to send e-mail message from PL/SQL routine.');
END;