How best to leverage basic SMTP operations in APIGEE

Not applicable

I would like to send an email to an APIGEE developer. Is this possible with a javascript policy. If so, how and with what preliminaries?

1 5 831
5 REPLIES 5

Can you elaborate? Are you looking for options to send emails on a Request/Response flow? or is it specific to sending emails to developers in Apigee on a particular condition?

I would like to send emails on a Request flow after extracting elements of the request body and performing pre-processing. I am however equally as interested in potential solutions for sending emails to developers in APIGEE on particular conditions.

The way I have sent emails in the past, from within the scope of an API Proxy in Edge, was using an HTTP-accessible mail service. For example http://mandrill.com/ .

I used a ServiceCallout policy to send the email. Like this:

<ServiceCallout name='SC-2'>
  <DisplayName>SC-2</DisplayName>
  <Request variable='quota.alert.mail.request' clearPayload='false'>
  <Set>
    <Payload contentType='application/json'
             variablePrefix='$' variableSuffix='#'><![CDATA[{
    "key": "my-mandrill-key",
    "raw_message": "From: DChiesa@apigee.com\nTo: $developer.email#\nSubject: API usage alert for $apiproduct.name#\n\nYour usage of the $apiproduct.name# API has reached $quota.usage.ratio#%.",
    "from_email": "DChiesa@apigee.com",
    "from_name": "Dino Chiesa",
    "async": false,
    "return_path_domain": null
}]]></Payload>
    <Headers>
      <Header name="content-type">application/json</Header>
    </Headers>
    <Verb>POST</Verb>
  </Set>
  </Request>
  <Response>quota.alert.mail.response</Response>
  <HTTPTargetConnection>
    <Properties>
      <Property name='success.codes'>2xx</Property>
    </Properties>
    <URL>https://mandrillapp.com/api/1.0/messages/send-raw.json</URL>
  </HTTPTargetConnection>
</ServiceCallout>

Note: You would have to signup with mandrill or another similar API-accessible email service, to use this approach.

You can also post messages to slack or hipchat this way, or send alerts to other systems that expose HTTP endpoints.

**Edit: I didn't realize this when I wrote the above, but Mandrill is apparently shutting down their service.

Thanks for your solution, unfortunately a third-party mail server outside of APIGEE isn't a possibility for this projects. I was hoping to leverage built in features and send mail through APIGEE to an administrator who is an APIGEE developer.

Hi,

I am also trying to achieve a solution like this. But I want to use a different server and want to trigger email to admin when a new app is created from the Integrated Dev portal connected with my Apigee Edge.

As I could not find any out of the box solution, I am thinking to create a proxy to send admin notification mail whenever a new app is created in the edge(assuming dev portal is always in sync with apigee edge).

Please correct me if I am wrong and please do help me to create proxy with any sample. I am new to Apigee and any help will be appreciated.