Advanced networking support

The following code example is supported by the following advanced networking options.

Ensure the the appropriate advanced networking configuration has been set up prior to following this tutorial.

OSGi configuration

This OSGi configuration example configures AEM’s Mail OSGi Service to use an external mail service, by way of the following Cloud Manager portForwards rule of the enableEnvironmentAdvancedNetworkingConfiguration operation.

...
"portForwards": [{
    "name": "smtp.mymail.com",
    "portDest": 465,
    "portOrig": 30465
}]
...
  • ui.config/src/jcr_root/apps/wknd-examples/osgiconfig/config/com.day.cq.mailer.DefaultMailService.cfg.json

Configure AEM’s DefaulMailService as required by your email provider (e.g. smtp.ssl, etc.).

{
    "smtp.host": "$[env:AEM_PROXY_HOST;default=proxy.tunnel]",
    "smtp.port": "30465",
    "smtp.user": "$[env:EMAIL_USERNAME;default=myApiKey]",
    "smtp.password": "$[secret:EMAIL_PASSWORD]",
    "from.address": "noreply@wknd.site",
    "smtp.ssl": true,
    "smtp.starttls": false,
    "smtp.requiretls": false,
    "debug.email": false,
    "oauth.flow": false
}

The EMAIL_USERNAME and EMAIL_PASSWORD OSGi variable and secret can be set per environment, using either:

  • Cloud Manager Environment Configuration

  • or using the aio CLI command

    $ aio cloudmanager:set-environment-variables --programId=<PROGRAM_ID> <ENVIRONMENT_ID> --secret EMAIL_USERNAME "myApiKey" --secret EMAIL_PASSWORD "password123"
    
recommendation-more-help