请帮帮我,我正在尝试从Oracle数据库11g发送邮件,在从数据库发送邮件时,我收到以下错误。
CREATE OR REPLACE PROCEDURE send_mail_deepak_test (p_to IN VARCHAR2,
p_from IN VARCHAR2,
p_subject IN VARCHAR2,
p_message IN VARCHAR2,
p_smtp_host IN VARCHAR2,
p_smtp_port IN NUMBER DEFAULT 25)
AS
l_mail_conn UTL_SMTP.connection;
BEGIN
l_mail_conn := UTL_SMTP.open_connection(p_smtp_host, p_smtp_port);
UTL_SMTP.helo(l_mail_conn, p_smtp_host);
UTL_SMTP.mail(l_mail_conn, p_from);
UTL_SMTP.rcpt(l_mail_conn, p_to);
UTL_SMTP.open_data(l_mail_conn);
UTL_SMTP.write_data(l_mail_conn, 'Date: ' || TO_CHAR(SYSDATE, 'DD-MON-YYYY HH24:MI:SS') || UTL_TCP.crlf);
UTL_SMTP.write_data(l_mail_conn, 'To: ' || p_to || UTL_TCP.crlf);
UTL_SMTP.write_data(l_mail_conn, 'From: ' || p_from || UTL_TCP.crlf);
UTL_SMTP.write_data(l_mail_conn, 'Subject: ' || p_subject || UTL_TCP.crlf);
UTL_SMTP.write_data(l_mail_conn, 'Reply-To: ' || p_from || UTL_TCP.crlf || UTL_TCP.crlf);
UTL_SMTP.write_data(l_mail_conn, p_message || UTL_TCP.crlf || UTL_TCP.crlf);
UTL_SMTP.close_data(l_mail_conn);
UTL_SMTP.quit(l_mail_conn);
END;
/
答案 0 :(得分:0)
信息很清楚。认证
base64username := UTL_RAW.cast_to_varchar2(UTL_ENCODE.base64_encode(UTL_RAW.cast_to_raw('a@b.com')));
base64password := UTL_RAW.cast_to_varchar2(UTL_ENCODE.base64_encode(UTL_RAW.cast_to_raw('1234')));
con:= UTL_SMTP.open_connection('myhost', 25);
UTL_SMTP.ehlo(con, smtpHost);
UTL_SMTP.command(con, 'AUTH', 'LOGIN');
UTL_SMTP.command(con, base64username );
UTL_SMTP.command(con, base64password );
另一个解决方案 - 就像提到的@FDavidoc一样 - 要求你的管理员降低你的机器的安全性,并允许发送没有Auth的邮件。这样您就不必担心密码了。
答案 1 :(得分:0)
也许您的p_to变量包含多个电子邮件收件人。 我有这个错误的原因。 如果要发送多个收件人:您应该查看this答案。