Skip to Main Content
Feature Request FR-2919
Status CLOSED

5 Voters

Use Multi smtp/mail server and compare pages

magdi.girgis Internal
· Jan 4 2023

I have an application serve many customers and each customer has his own smtp /mail server , I want to do something dynamic so I can choose customer's smtp to send email/attached report or whatever using his own smtp , Oracle apex/database only allow one smtp for each instance which is not make sense .

Compare pages :
I have developer application then delivered to customer /productions , later on I have add new features and extra code for page 10 for Example, How should i do to replace page without losing old one and new one with extra code .
must be some tools there to compare and apply like get hub,version contorl , other tools and keep all version of my code etc..

Use Case
What are the use cases in which this idea useful?

Preferred Solution (Optional)
How would you implement this idea? If you are not sure, leave blank.

This idea has been closed due to the lack of community activity during the period since it was submitted.

Comments

Comments

  • jayson hanes Admin OP 2.5 years ago

    @magdi.girgis please create a new submission for the “compare pages” idea

  • doug.gault OP 2.5 years ago

    For the email-problem. You'll likely have to step back to using something like UTL_SMTP and code our own PL/SQL packages to handle this.

    IMHO this is the only SANE way to do this as the requirements and settings for each client's mail server(s) may be vastly different depending on the mail services they use.

    APEX MAIL isn't set up for this, so you'll have to roll-your-own.

  • werner OP 2.4 years ago

    I used UTL_SMTP in PlSql-Package, in this way You can send mails to different Mail-Gateways. Works fine, fast and very stable.

  • magdi.girgis OP 2.4 years ago

    @werner would you please share code or sample .

  • werner OP 2.4 years ago

    Created a function sendUtlSmtp passing username, tenance_id and p_mail, record contains mail-data line from, to, subject and body. With this procedure I send about 1000 mails per day from Apex calling this stored proc

    function sendUtlSmtp(
     p_user_name      in cmn_user_account.account_code%type,
     p_company_id     in sys_company.id%type,
     p_mail           in sys_mail%rowtype
     ) return number IS

     c                   UTL_SMTP.CONNECTION;

     l_mail_host         varchar2(80);
     l_mail_helo         varchar2(80);
     l_header_sender     varchar2(80);

     PROCEDURE send_header(name IN VARCHAR2, header IN VARCHAR2) AS
     BEGIN
       UTL_SMTP.WRITE_DATA(c, name || ': ' || header || UTL_TCP.CRLF);
     END;

    begin
    -- Hostname stored in the tenance-properties, DNS-name or IP-Address
     l_mail_host     := sys_company_pkg.getProperty(p_user_name,p_company_id,'MAIL','HOSTNAME');
     
    -- HELO stored in the tenance-properties, tenance mail, example finova.it
     l_mail_helo     := sys_company_pkg.getProperty(p_user_name,p_company_id,'MAIL','HELO');
     
    -- Sender stored in the tenance-properties, example 'ServiceDesk.Finova'
     l_header_sender := nvl(sys_company_pkg.getProperty(p_user_name,p_company_id,'MAIL','HEADER_SENDER'),'Sender');

     c := UTL_SMTP.OPEN_CONNECTION(l_mail_host);
     UTL_SMTP.HELO(c, l_mail_helo);
     UTL_SMTP.MAIL(c, p_mail.mail_from);
     UTL_SMTP.RCPT(c, p_mail.mail_to);

    -- Parameter p_mail - type of record, contains mail-informations, next lines only for demonstration
    p_mail.mail_from := 'Werner@finova.it';
    p_mail.mail_to   := 'madgi.yayoo.com';
    p_mail.mail_subj := 'Smtp-Example';
    p_mail.mail_clob := 'Greetings';
    -- end assignement for demo
     
     UTL_SMTP.OPEN_DATA(c);
     send_header('From',    '"' || l_header_sender || '" <' || p_mail.mail_from || '>');
     send_header('To',      '"Recipient" <' || p_mail.mail_to || '>');
     send_header('Subject', p_mail.mail_subj);
     UTL_SMTP.WRITE_DATA(c, p_mail.mail_clob);
     UTL_SMTP.CLOSE_DATA(c);
     UTL_SMTP.QUIT(c);

     return 0;
    end sendUtlSmtp;
     

    Don't forget Network-ACL smtp and file_utl.

    Hope this helps

  • magdi.girgis OP 2.4 years ago

    Many thanks, but you don't need to set evetime you change smtp in database ,

    sys_company_pkg.getProperty(p_user_name,p_company_id,'MAIL','HEADER_SENDER'),'Sender'

    this part to just get info not set something related to smtp in database ?? right?

  • werner OP 2.4 years ago

    Right. I apply this only to add a sender this string to the mail-from.