Skip to Main Content

Breadcrumb

Question and Answer

Connor McDonald

Thanks for the question, Tamil selvan.

Asked: June 20, 2018 - 8:03 am UTC

Last updated: June 22, 2018 - 3:03 am UTC

Version: 12C

Viewed 1000+ times

You Asked

Hi Tom,

I have a requirement to send email to particular domain mail id’s. But My Mail server is global mail server we can send mail to any mail ids. Is there any options in Oracle to restrict the mail send as global.
For example: My mail host is, mail.abc.com which is webmail. I have to send mail to only the mail ids which belongs abc.com.

Thanks
Tamilselvan R

and Connor said...

By default, UTL_SMTP is granted to public but it certainly does not have to be. Hence you could easily revoke that privilege and put a wrapper procedure around it to lock down certain elements. eg

procedure mail_wrapper(p_recipient varchar2, p_content varchar2, ... ) is
begin
  if lower(p_recipient) not like '%@%abc.com' then
      raise_application_error(-20000,'You can only email domain abc.com');
  end if;
  
  ...
  ... rest of normal calls to utl_smtp
  ...
end;


and then you grant execute on mail_wrapper to the people that need it.

Is this answer out of date? If it is, please let us know via a Comment

More to Explore

PL/SQL demos

Check out more PL/SQL tutorials on our LiveSQL tool.

PL/SQL docs

PL/SQL reference manual from the Oracle documentation library