oracle mail utl_smtp

liangxichen發表於2007-01-25

DECLARE
c utl_smtp.connection;
PROCEDURE send_header(name IN VARCHAR2, header IN VARCHAR2) AS
BEGIN
utl_smtp.write_data(c, name || ': ' || header || utl_tcp.CRLF);
END;
BEGIN
-- << 用你的SMTP伺服器地址替換 'smtp.xxx.com'
c := utl_smtp.open_connection('smtp.xxx.com');

-- << 用你的使用者名稱替換user1, 密碼替換pass

-- << 用你的SMTP伺服器地址替換 'smtp.xxx.com'
utl_smtp.helo(c, 'smtp.xxx.com');

utl_smtp.command(c, 'AUTH LOGIN');
utl_smtp.command(c, utl_raw.cast_to_varchar2(utl_encode.base64_encode(utl_raw.cast_to_raw('user'))));
utl_smtp.command(c, utl_raw.cast_to_varchar2(utl_encode.base64_encode(utl_raw.cast_to_raw('password'))));

-- << 用你的email地址替換
utl_smtp.mail(c, );
-- << 用收信人的email地址替換
utl_smtp.rcpt(c, );
utl_smtp.open_data(c);

send_header('From', 'send_header('To', '

utl_smtp.write_data(c, utl_tcp.CRLF || 'Hello, microsoft, I like oracle not sql server :-)');
utl_smtp.close_data(c);
utl_smtp.quit(c);

END;

utl_smtp.write_raw_data(c, utl_raw.cast_to_raw(
convert( 'Subject:'||v_email_title|| utl_tcp.CRLF ,'ZHS16GBK') ) ); --寫標題

utl_smtp.write_raw_data(c, utl_raw.cast_to_raw(
convert(utl_tcp.CRLF || v_email_content ,'ZHS16GBK') )); --寫正文

send_header('Content-type','text/plain; charset=utf-8');
send_header('Content-type','text/html; charset=utf-8');

[@more@]

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/59792/viewspace-893493/,如需轉載,請註明出處,否則將追究法律責任。

相關文章