Customer Portal

Get Involved. Join the Conversation.


    Jason Raynor
    Email 'how to' guide using smtpmail()
    Topic posted August 4, 2010 by Jason RaynorRed Ribbon: 250+ Points, last edited October 29, 2011 
    2245 Views, 8 Comments
    Email 'how to' guide using smtpmail()

    Hello everybody,

    Just thought I would post a bit of information on this function as if you are anything like me it is hard to find any info out there on how to use this so here we go,

    To be able to call this from you model you will first need to do the below:

    1. You will need to get SEC_CP_ADDTL_FCN_USAGE setting enabled for you site.
    2. add: “smtpmail,<your model name>.php” to the list.

    Now that the function is enabled and can be called without error here are some examples of using it:

    Send a standard email with cc

    $mail = array('to' => $to,
                 'from'  => $from,
                 'subject' => $subject,
                 'cc' => $cc,
                 'body' => $body);

    AbuseDetection::check(); //May 10 +

              return “hey, it worked”;
              return “Opps, something went wrong”;

    Send a html email:

    $mail = array('to' => $to,
                 'from'  => $from,
                 'subject' => $subject,
                 'cc' => $cc,
                'html' => $html,
                 'body' => $body);

    Send a email with attachment;

    $mail = array('to' => $to,
                 'from'  => $from,
                 'subject' => $subject,
                 'body' => $body);

    // add any attachments (assumes attachments where uploaded via RightNow)

    $fa_dir = "../../../../file_attachments/";
    $sql  = sprintf("SELECT localfname, userfname, content_type FROM fattach WHERE tbl=1 AND id=%d",$i_id);

    $si  = sql_prepare($sql);

    sql_bind_col($si, 1, BIND_NTS, 255);
    sql_bind_col($si, 2, BIND_NTS, 255);
    sql_bind_col($si, 3, BIND_NTS, 255);

    $i = 1;

    while($row = sql_fetch($si)) { //iterate through result set
         $mail['fattach' . $i]['userfname']    = $row[1];
         $mail['fattach' . $i]['localfname']   = $fa_dir . $row[0];
         $mail['fattach' . $i]['content_type'] = $row[2];


    sql_free($si); // IMPORTANT



    Hope this helps some of you out there,



    • Steven Conroy


    • Pramod Vasudeva Murthy

      Hi Jason,

      Thanks for this post.

      I have a few questions about this.

      1. Is this config setting deprecated in higher versions or re-named?[May 10 onwards]

      2. Assuming it's not deprecated I am trying the same with a demo instance. I have my 'send email' [smtpmail($mail)] embedded in a PHP page. And following is my configuration setting:

      SEC_CP_ADDTL_FCN_USAGE: 'smtpmail','/app/send_email/email_2' 

      As the above config setting takes two parameters: <function_name>,<path_of_PHP_script>

      I have a Custom Ask A Question Page upon submit, navigating to email_2.PHP. In this page, I am reading values of form and trying to send an email.

      Am I doing this correctly?

      3. Should I embed email sending in model and give the model in config setting?

      Please suggest.

      Thanks & Regards,

      Pramod V


    • Luuk

      @Pramod V:

      The SMTPmail has been deprecated for some time now.  There is a replacement function in the Aug. 14 and later release.
      This is called the "Public Mail API" and is very well documenten in the technical documentation from Aug 14. and later.

    • Pramod Vasudeva Murthy

      Thank you Luuk for responding.

      But currently the site I am experimenting is

      Right-now Customer Portal v2
      Software Version:Oracle RightNow CX Cloud Service May 2014 (Build 119) SP3
      So this options out as its not Aug 2014.
      However, I observed that there are API's built in JS which is used to send emails.
      For eg:

      Do you think this works in RN environment?

      Also, one of the members from expert panel suggested to expose Mail API functions in other Server and consume them as Web-service in RN CP.

      But my concern is, SMTP email and PHP mailer functions are default exposed by PHP libraries for sending emails. Why wouldn't the Model pick up those defnitions at run-time? It gives a 'Method undefined error' when I try to use 'smtpemail()' function.

      Please advice.


      Pramod V



    • Jeremy Watson


      For security purposes, many seemingly standard PHP functions are not enabled with the PHP library that is available on an Oracle Cloud Service site.  As you mention above, you might be able to setup outgoing connections to a different server that would then provide the email sending capabilities that you are looking for.  If you attempt to use the SEC_CP_ADDTL_FCN_USAGE config, your calling script will need to be a model file.


    • Pramod Vasudeva Murthy

      Thank you very much James for responding. I will set up the configuration as suggested and try it out. 

    • Pramod Vasudeva Murthy

      Hi ALL,

      As suggested by Experts on this thread; I am able to send an email from a custom page using Public Mail API.

      But I am stuck at Attachments. I have following confirmations to make?

      1. I am using FileAttachment Upload widget. Can I read in my model about following information?

      File type, File Size, File Name, File Data

      2. Currently I am referring to this link:

      How do I create a FileAttachment Object and populate with above data?

      3. Can I use $_FILES here?

      Please suggest.

    • Pramod Vasudeva Murthy

      Fellow Rightnow Lovers,

      I am able to achieve above functionality. I used FileAttachment object and populated it's values accordingly. BTW, $_FILES works in model of(Aug 2014).

      Thanks for the support from communitylaugh