Skip to Main Content

Breadcrumb

Question and Answer

Connor McDonald

Thanks for the question, Radhika.

Asked: May 13, 2021 - 1:43 am UTC

Last updated: May 14, 2021 - 6:37 am UTC

Version: 19c

Viewed 1000+ times

You Asked

In the Example of Multiple Recipients in the

https://oracle-base.com/articles/misc/email-from-oracle-plsql#multiple-recipients

link, mail goes to all the recipients. But, all the names in the "To" list is available to all the recipients.Is there any parameter setting such that, only the intended recipients name appears. So that each recipient is not aware of other names in the "To" list.


and Connor said...

Yes. You add them add using RCPT but the message content can control whether they are CC or BCC, eg some sample code below

  l_conn := utl_smtp.open_connection(c_mail_server, 25);

  utl_smtp.helo(l_conn, c_mail_server);
  utl_smtp.mail(l_conn, c_mail_from );
  for i in 1 .. p_recip.count loop
    utl_smtp.rcpt(l_conn, p_recip(i));
  end loop;

  l_mesg := l_mesg || 'MIME-Version: 1.0' ||  crlf;
  l_mesg := l_mesg || 'To: ' || p_recip(1) || crlf;
  for i in 2 .. p_recip.count loop
    l_mesg := l_mesg || 'Cc: ' || p_recip(i) || crlf;
  end loop;
  l_mesg := l_mesg || 'From: ' || c_mail_from||crlf;
  l_mesg := l_mesg || 'Subject: ' || l_db_name || '-' || p_subject|| crlf;
  l_mesg := l_mesg || 'Reply-To: ' || c_mail_from  ||  crlf;


Rating

  (3 ratings)

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

Comments

A reader, May 14, 2021 - 7:01 am UTC

This does not seem to work as

this gives the first name in the list to all the recipients who gets the mail.
What we need, is the emailid of the person receiving the mail in the to clause.

JonW, May 14, 2021 - 2:22 pm UTC

The standard way to do this is to send the message to yourself and blind copy everyone that you want the message to go to.

So, if you change the 'To: to be from c_mail_from and change the "Cc:" to "Bcc:", that should probably give you what you need.

rad, May 15, 2021 - 12:06 am UTC

Thanks, I was looking for adding it as "To" and the address as personal to the User. Anyways thanks for the quick response.

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