ITPub博客

首页 > Linux操作系统 > Linux操作系统 > mail设置

mail设置

原创 Linux操作系统 作者:dingyu220 时间:2012-04-16 17:07:02 0 删除 编辑
--发送邮件
PROCEDURE P_SEND_MAIL
  (IV_RECIPIENT IN VARCHAR2 DEFAULT 'aaa@163.com', --收件人
  IV_MESSAGE IN VARCHAR2 DEFAULT 'The data is ', --标题
  IV_SUBJECT IN VARCHAR2 DEFAULT 'Oracle Report '|| TO_CHAR (SYSDATE, 'yyyy-mm-dd hh24:mi:ss'), --内容
  IV_SENDER IN VARCHAR2 DEFAULT 'bbb@163.com') --收件人
IS
  v_mailhost VARCHAR2 (30) := 'mail.163.com';
  mail_conn UTL_SMTP.connection;
  msg VARCHAR2 (32767);
  v_crlf VARCHAR2(2) := CHR(13)||CHR(10);
  p_user VARCHAR2 (30) := 'aaa';
  p_pass VARCHAR2 (30) := 'aaa';
BEGIN
  msg :=
  'Date:'
  ||TO_CHAR (SYSDATE, 'dd mon yy hh24:mi:ss')
  || UTL_TCP.crlf
  || 'From: '
  || IV_SENDER
  || '<'
  || IV_SENDER
  || '>'
  || UTL_TCP.crlf
  || 'To: '
  || IV_RECIPIENT
  || '<'
  || IV_RECIPIENT
  || '>'
  || UTL_TCP.crlf
  || 'Subject: '
  || IV_SUBJECT
  || UTL_TCP.crlf
  || UTL_TCP.crlf
  || IV_MESSAGE;
  mail_conn := UTL_SMTP.open_connection (v_mailhost, 25);
  UTL_SMTP.helo (mail_conn, v_mailhost);
  UTL_SMTP.command (mail_conn, 'AUTH LOGIN');
  UTL_SMTP.command (mail_conn,
  UTL_RAW.cast_to_varchar2
  (UTL_ENCODE.base64_encode
  (UTL_RAW.cast_to_raw (p_user)
  )
  )
  );
  UTL_SMTP.command (mail_conn,
  UTL_RAW.cast_to_varchar2
  (UTL_ENCODE.base64_encode (UTL_RAW.cast_to_raw (p_pass)
  )
  )
  );
  UTL_SMTP.mail (mail_conn, IV_SENDER);
  UTL_SMTP.rcpt (mail_conn, IV_RECIPIENT);
  UTL_SMTP.DATA (mail_conn, msg);
  UTL_SMTP.QUIT(mail_conn);

  NULL;
END P_SEND_MAIL;

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/24805255/viewspace-721345/,如需转载,请注明出处,否则将追究法律责任。

下一篇: merge into用法
请登录后发表评论 登录
全部评论

注册时间:2011-05-15

  • 博文量
    67
  • 访问量
    60478