Mailgun Ruby Reads the Proxy When Its Client Is Created
Set Mailgun.proxy_url before creating a current Faraday-based Mailgun::Client, keeping the API host and key separate.
The Faraday-based Mailgun Ruby client reads Mailgun.proxy_url when it is constructed. Set that default first:
require 'mailgun-ruby'
Mailgun.proxy_url = ENV.fetch('OUTBOUND_PROXY')
client = Mailgun::Client.new(api_key, api_host)
OUTBOUND_PROXY can contain a URL such as http://proxy.example:8080. An endpoint from the HTTP proxy list can supply a public HTTP route for this value. Keep api_key and api_host as the application’s Mailgun settings, including its intended regional API hostname.
The constructor passes proxy_url to Faraday’s proxy option and configures the API account separately. A later change to Mailgun.proxy_url leaves an existing client’s stored Faraday connection unchanged.
proxy_url is also accepted as the constructor’s seventh positional argument. Use the application’s established configuration style so that position remains understandable.
Older mailgun-ruby releases used RestClient. A RestClient.proxy assignment applies to that transport generation; check the installed SDK before adapting it to a Faraday-based client.