This site is currently read-only as we are migrating to Oracle Forums for an improved community experience. You will not be able to initiate activity until January 30th, when you will be able to use this site as normal.

    Forum Stats

  • 3,889,990 Users
  • 2,269,775 Discussions
  • 7,916,823 Comments

Discussions

Need to send an email with attachment from opa

Hi Team,

We are trying to send an email from opa with an attachment. and also we don't want to use  an emailing service like mailgun or mandrill, because we have our own SMTP server.

Request everyone to please feel free to let know any feasible technical ideas for achieving the same in OPA.


Thanks & Regards

Rakesh

Best Answer

  • Richard Napier
    Richard Napier EuropeMember Posts: 546 Bronze Trophy
    edited Nov 3, 2022 9:55AM Answer ✓

    Hi

    I find it interesting that I was asked this question on another forum yesterday. Perhaps you work with Aarti. So I'm going to go through the different answers I gave yesterday and see if the responses resonate with you. I have a degree of experience in this area.

    My first response, and I would really appreciate a reply, is why? Given the following

    1) External Email Services like mailgun,mandrill etc all use MX records to send email from a subdomain of your clients site (eg "mail.myserver.com") so the process is transparent for the end recipient, the email still appears to come from your client.

    2) These services typically have thousands of emails for free per quarter, before billing starts.

    3) These services provide heavy-duty logging, reputation tracking, bounce tracking and more as part of their console.

    4) These services provide an easy to consume wrapper in the form of a REST API

    5) The potential reputational damage to a client who decides to use their own internal SMTP server for sending emails from an application but who discovers that many of the automated emails get marked as spam, impacting others sending emails from the same server.

    So, why do they want to do this? Sometimes our job is to explain to a client that what they want is not actually the best solution, and I think this may be one of those cases.

    Putting that aside:

    1) Sending email from JavaScript in today's modern world of authenticated, non-relaying email servers is just not worth trying to achieve, in my opinion. There are a few solutions out there but nothing worth investing time in for a professional solution. It is possible to send email from OPA, but not directly. See the following points

    2) It is possible, and indeed quite simple, to send email from OPA via PHP or indeed via Oracle B2C Service Mail API (or another platform) if you so require.

    If you are using B2C Service and want to include a dynamic attachment : This could be done in theory via a custom script/process, as there is a PHP Mail API that allows sending emails with an attachment, but this a custom email. The attachment would need to be added to the incident first, save the fattach ID somewhere, then trigger custom process to send email using that fattach ID.

    3) If you are using Visual Builder Cloud Service, you could use Send Email Notification.

    4) If you are not using any other Oracle Cloud software you could just write a simple PHP page to do this using the PHPMailer library. Pass the details of the email to the PHP page by calling it from a JavaScript Extensions, and send it from there.

    See https://github.com/PHPMailer/PHPMailer/tree/master/examples for some simple examples. The core PHP mail() function can also be configured to use SMTP, but if you don't want to affect any other PHP applications that may be using mail() then PHPMailer() is the easier option, plus mail() is very limited.

    You do need to be careful with the construction of the email using PHPMailer, and be aware that some anti-spam gateways (Spam Assassin, etc) detect emails sent from PHPMailer and mark them as "probable spam")

    It would definitely help if you answer the folllowing questions

    1) Why do they want to do this?

    2) What is the landscape around OPA - what CX, what integration server, what other applications...

    Hope that helps!

Answers

  • Richard Napier
    Richard Napier EuropeMember Posts: 546 Bronze Trophy
    edited Nov 3, 2022 9:55AM Answer ✓

    Hi

    I find it interesting that I was asked this question on another forum yesterday. Perhaps you work with Aarti. So I'm going to go through the different answers I gave yesterday and see if the responses resonate with you. I have a degree of experience in this area.

    My first response, and I would really appreciate a reply, is why? Given the following

    1) External Email Services like mailgun,mandrill etc all use MX records to send email from a subdomain of your clients site (eg "mail.myserver.com") so the process is transparent for the end recipient, the email still appears to come from your client.

    2) These services typically have thousands of emails for free per quarter, before billing starts.

    3) These services provide heavy-duty logging, reputation tracking, bounce tracking and more as part of their console.

    4) These services provide an easy to consume wrapper in the form of a REST API

    5) The potential reputational damage to a client who decides to use their own internal SMTP server for sending emails from an application but who discovers that many of the automated emails get marked as spam, impacting others sending emails from the same server.

    So, why do they want to do this? Sometimes our job is to explain to a client that what they want is not actually the best solution, and I think this may be one of those cases.

    Putting that aside:

    1) Sending email from JavaScript in today's modern world of authenticated, non-relaying email servers is just not worth trying to achieve, in my opinion. There are a few solutions out there but nothing worth investing time in for a professional solution. It is possible to send email from OPA, but not directly. See the following points

    2) It is possible, and indeed quite simple, to send email from OPA via PHP or indeed via Oracle B2C Service Mail API (or another platform) if you so require.

    If you are using B2C Service and want to include a dynamic attachment : This could be done in theory via a custom script/process, as there is a PHP Mail API that allows sending emails with an attachment, but this a custom email. The attachment would need to be added to the incident first, save the fattach ID somewhere, then trigger custom process to send email using that fattach ID.

    3) If you are using Visual Builder Cloud Service, you could use Send Email Notification.

    4) If you are not using any other Oracle Cloud software you could just write a simple PHP page to do this using the PHPMailer library. Pass the details of the email to the PHP page by calling it from a JavaScript Extensions, and send it from there.

    See https://github.com/PHPMailer/PHPMailer/tree/master/examples for some simple examples. The core PHP mail() function can also be configured to use SMTP, but if you don't want to affect any other PHP applications that may be using mail() then PHPMailer() is the easier option, plus mail() is very limited.

    You do need to be careful with the construction of the email using PHPMailer, and be aware that some anti-spam gateways (Spam Assassin, etc) detect emails sent from PHPMailer and mark them as "probable spam")

    It would definitely help if you answer the folllowing questions

    1) Why do they want to do this?

    2) What is the landscape around OPA - what CX, what integration server, what other applications...

    Hope that helps!

  • User_YQZCL
    User_YQZCL Member Posts: 11 Green Ribbon

    Hi Richard,

    Thanks for the brief explanation. It was very helpful to us.

    We have implemented one use case where we want to send emails with attachments via OPA. There is integration between OPA, OIC, and VBCS. We want to send BI report generated by OPA through email to the end user.

    We will discuss all the Pros and cons with the client and let you know if any other concerns on the same.

    Thanks.

  • Richard Napier
    Richard Napier EuropeMember Posts: 546 Bronze Trophy

    HI

    Oh and I forgot, for anyone who is interested, there is an example of using an external service to send an email with an attachment here from Oracle Intelligent Advisor using REST APIs :

    Part One (Without Attachment)

    Part Two (With Attachment of PDF Form)

    R