我在APEX_INSTANCE上配置了一个电子邮件帐户,SMTP服务器,端口等。调用APEX的send_mail函数可以正常工作。
现在,我需要从其他帐户发送邮件,例如:有时我需要从sales@example.com发送邮件,而另一次需要从customer@example.com发送邮件。
我的问题是:
有什么方法可以在运行时指定电子邮件帐户配置吗?
我使用Oracle Apex 19。
答案 0 :(得分:0)
如果您使用apex_mail.send发送电子邮件,则可以为每封电子邮件指定发送帐户。有参数p_from
。检查docs。
如果要在运行时更改smtp设置,请选中APEX_INSTANCE_ADMIN.SET_PARAMETER。我尚未验证这一点,但是文档中的示例表明它也可以用于更改电子邮件设置。
答案 1 :(得分:0)
declare
v_INVONO VARCHAR2(20);
V_TOTAL number;
v_MOBILE varchar2(50);
v_email varchar2(50);
V_MST_ID NUMBER;
v_body_html CLOB;
v_add varchar2(500);
v_city varchar2(100);
v_order_lines clob;
V_PAYMENT number;
begin
select PHONE INTO v_MOBILE FROM CUSTOMER_INFO WHERE CUST_ID = :GLOBAL_CUSTOMER_ID;
select EMAIL,address,city INTO v_email,v_add,v_city FROM APP_USERS WHERE upper(USERNAME) = upper(:APP_USER);
select sum(c002*c003) into V_TOTAL from apex_collections c
where c.collection_name = 'CUST_ORDER_ITEMS' and nvl(c003,0)>0;
select lpad(nvl(max(to_number(INVONO))+1,1),6,0) into v_INVONO from SALES_MST;
V_PAYMENT:=V_TOTAL-NVL(:discount_perc,0);
INSERT INTO SALES_MST (
INVONO, INVO_DATE, CUST_ID,
CUST_NAME, MOBILE, TOTAL,
DISCOUNT, SUB_TOTAL, PAYMENT,
DUE, USER_ID, ORDER_STATUS,ORDER_TIME, ORDER_EXPIRY_TIME)
VALUES
( v_INVONO,
sysdate,
:customer_id,
:customer_name,
v_MOBILE,
V_TOTAL,
:P13_DISC_PERC,
V_TOTAL,
V_TOTAL-NVL(:P13_DISC_PERC,0),
null,
null,'IP',SYSDATE, SYSDATE+((1/24)/60)*20 )
RETURN ID,
INVONO INTO V_MST_ID,
:P10_ORDER_NO;
v_body_html:='<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Email Template email from apex </title>
<!-- Start Common CSS -->
<style type="text/css">
#outlook a {padding:0;}
body{width:100% !important; -webkit-text-size-adjust:100%; -ms-text-size-adjust:100%; margin:0; padding:0; font-family: Helvetica, arial, sans-serif;}
.ExternalClass {width:100%;}
.ExternalClass, .ExternalClass p, .ExternalClass span, .ExternalClass font, .ExternalClass td, .ExternalClass div {line-height: 100%;}
.backgroundTable {margin:0; padding:0; width:100% !important; line-height: 100% !important;}
.main-temp table { border-collapse:collapse; mso-table-lspace:0pt; mso-table-rspace:0pt; font-family: Helvetica, arial, sans-serif;}
.main-temp table td {border-collapse: collapse;}
</style>
<!-- End Common CSS -->
</head>
<body>
<table width="100%" cellpadding="0" cellspacing="0" border="0" class="backgroundTable main-temp" style="background-color: #d5d5d5;">
<tbody>
<tr>
<td>
<table width="600" align="center" cellpadding="15" cellspacing="0" border="0" class="devicewidth" style="background-color: #ffffff;">
<tbody>
<!-- Start header Section -->
<tr>
<td style="padding-top: 30px;">
<table width="560" align="center" cellpadding="0" cellspacing="0" border="0" class="devicewidthinner" style="border-bottom: 1px solid #eeeeee; text-align: center;">
<tbody>
<tr>
<!--<td style="padding-bottom: 10px;">
<a href="https://htmlcodex.com"><img src="images/logo.png" alt="PapaChina" /></a>
</td>-->
<strong>organization name</strong>
</tr>
<tr>
<td style="font-size: 14px; line-height: 18px; color: #666666;">
street 42 park line
</td>
</tr>
<tr>
<td style="font-size: 14px; line-height: 18px; color: #666666;">
city, state, postal_code
</td>
</tr>
<tr>
<td style="font-size: 14px; line-height: 18px; color: #666666;">
Phone: 123-456-786 | Email: abc@abc.com
</td>
</tr>
<tr>
<td style="font-size: 14px; line-height: 18px; color: #666666; padding-bottom: 25px;">
<strong>Order Number:</strong> '||v_INVONO||' | <strong>Order Date:</strong> '||sysdate||'
</td>
</tr>
</tbody>
</table>
</td>
</tr>
<!-- End header Section -->
<!-- Start address Section -->
<tr>
<td style="padding-top: 0;">
<table width="560" align="center" cellpadding="0" cellspacing="0" border="0" class="devicewidthinner" style="border-bottom: 1px solid #bbbbbb;">
<tbody>
<tr>
<td style="width: 55%; font-size: 16px; font-weight: bold; color: #666666; padding-bottom: 5px;">
Delivery Adderss
</td>
<td style="width: 45%; font-size: 16px; font-weight: bold; color: #666666; padding-bottom: 5px;">
Billing Address
</td>
</tr>
<tr>
<td style="width: 55%; font-size: 14px; line-height: 18px; color: #666666;">
'||:customer_name||'
</td>
<td style="width: 45%; font-size: 14px; line-height: 18px; color: #666666;">
'||:customer_name||'
</td>
</tr>
<tr>
<td style="width: 55%; font-size: 14px; line-height: 18px; color: #666666;">
'||v_add||'
</td>
<td style="width: 45%; font-size: 14px; line-height: 18px; color: #666666;">
'||v_add||'
</td>
</tr>
<tr>
<td style="width: 55%; font-size: 14px; line-height: 18px; color: #666666;">
'||v_city||'
</td>
<td style="width: 45%; font-size: 14px; line-height: 18px; color: #666666;">
'||v_city||'
</td>
</tr>
</tbody>
</table>
</td>
</tr>
<!-- End address Section -->
<!-- Start product Section -->';
for i in (select c001,c002,c003,c004,c005 from apex_collections c
where c.collection_name = 'CUST_ORDER_ITEMS' and nvl(c003,0)>0)
loop
INSERT INTO SALES_DTLS (
INVONO, ID, DESCRIPTION,
UNIT, RATE, QTY,MST_ID)
VALUES ( v_INVONO,
i.c001,
i.c004,
i.c005,
i.c002,
i.c003 ,V_MST_ID);
v_order_lines := v_order_lines||
'<tr>
<td style="padding-top: 0;">
<table width="560" align="center" cellpadding="0" cellspacing="0" border="0" class="devicewidthinner" style="border-bottom: 1px solid #eeeeee;">
<tbody>
<tr>
<td colspan="2" style="font-size: 14px; font-weight: bold; color: #666666; padding-bottom: 5px;">
'||i.c004||'
</td>
</tr>
<tr>
<td style="font-size: 14px; line-height: 18px; color: #757575; width: 440px;">
Quantity: '||i.c003||'
</td>
<td style="width: 130px;"></td>
</tr>
<tr>
<td style="font-size: 14px; line-height: 18px; color: #757575;">
</td>
<td style="font-size: 14px; line-height: 18px; color: #757575; text-align: right;">
Rs. '||i.c002||' Per Unit
</td>
</tr>
<tr>
<td style="font-size: 14px; line-height: 18px; color: #757575; padding-bottom: 10px;">
</td>
<td style="font-size: 14px; line-height: 18px; color: #757575; text-align: right; padding-bottom: 10px;">
<b style="color: #666666;">Rs. '||(i.c003*i.c002)||'</b> Total
</td>
</tr>
</tbody>
</table>
</td>
</tr>';
end loop;
--v_order_lines := v_order_lines||'</table>';
v_body_html:=v_body_html||v_order_lines||'<!-- End product Section -->
<!-- Start calculation Section -->
<tr>
<td style="padding-top: 0;">
<table width="560" align="center" cellpadding="0" cellspacing="0" border="0" class="devicewidthinner" style="border-bottom: 1px solid #bbbbbb; margin-top: -5px;">
<tbody>
<tr>
<td style="font-size: 14px; font-weight: bold; line-height: 18px; color: #666666; padding-top: 10px;">
Order Total
</td>
<td style="font-size: 14px; font-weight: bold; line-height: 18px; color: #666666; padding-top: 10px; text-align: right;">
Rs. '||V_TOTAL||'
</td>
</tr>
<tr>
<td style="font-size: 14px; font-weight: bold; line-height: 18px; color: #666666;">
Discount:
</td>
<td style="font-size: 14px; font-weight: bold; line-height: 18px; color: #666666; text-align: right;">
Rs. '||NVL(:P13_DISC_PERC,0)||'
</td>
</tr>
<tr>
<td style="font-size: 14px; font-weight: bold; line-height: 18px; color: #666666; padding-bottom: 10px;">
Payment Amount
</td>
<td style="font-size: 14px; font-weight: bold; line-height: 18px; color: #666666; text-align: right; padding-bottom: 10px;">
Rs. '||V_PAYMENT||'
</td>
</tr>
</tbody>
</table>
</td>
</tr>
<!-- End calculation Section -->
<!-- Start payment method Section -->
<tr>
<td style="padding: 0 10px;">
<table width="560" align="center" cellpadding="0" cellspacing="0" border="0" class="devicewidthinner">
<tbody>
<tr>
<td colspan="2" style="font-size: 16px; font-weight: bold; color: #666666; padding-bottom: 5px;">
Payment Method ('||:P12_PAYMENT_OPTION||')
</td>
</tr>
<tr>
<td colspan="2" style="width: 100%; text-align: center; font-style: italic; font-size: 13px; font-weight: 600; color: #666666; padding: 15px 0; border-top: 1px solid #eeeeee;">
<b style="font-size: 14px;">Note:</b>
</td>
</tr>
</tbody>
</table>
</td>
</tr>
<!-- End payment method Section -->
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
</body>
</html>';
:order_id := V_MST_ID;
APEX_COLLECTION.DELETE_COLLECTION(
p_collection_name => 'CUST_ORDER_ITEMS');
if :card_save = 'Y' then
declare
v_count number;
begin
select count(*) into v_count from CUSTOMER_CARDS where card_number=:card_number;
if v_count = 0 then
INSERT INTO CUSTOMER_CARDS (
CUST_ID, NAME_ON_CARD,
CARD_NUMBER, EXPIRY_DATE, CVC)
VALUES ( :customer_id,
:card_name,
:card_number ,
:card_expiry,
:card_cvc);
else
update CUSTOMER_CARDS set NAME_ON_CARD=:P12_NAME_ON_CARD,EXPIRY_DATE=:card_expiry,
CVC=:card_cvc where card_number=:card_number;
end if;
end;
END IF;
IF :yourcodeid IS NOT NULL THEN
UPDATE CUSTOMER_VOUCHERS SET AVAILED='Y', AVAILED_DATE = SYSDATE
WHERE VOUCHER_ID = :your_voucher_id and cust_id = :your_customer_id;
END IF;
APEX_MAIL.SEND(
p_to =>v_email,
p_from =>'YOUR EMAIL ADDRESS',
p_body =>null,
p_body_html =>v_body_html,
p_subj =>'Order ('||v_INVONO||') Confirmed!',
p_cc => NULL,
p_bcc =>NULL,
p_replyto =>null
);
APEX_MAIL.PUSH_QUEUE;
END;