namespace :postageapp do desc 'Show the current PostageApp configuration' task config: :environment do puts "PostageApp Configuration" puts "------------------------" puts config = PostageApp.config puts "API Key: %s" % config.api_key puts "API Endpoint: %s" % config.url puts "Secure: %s" % [ config.secure? ? 'Yes' : 'No' ] if (config.proxy_host) puts "SOCKS5 Proxy: %s:%d" % [ config.proxy_host, config.proxy_port ] if (config.proxy_user) puts "SOCKS5 Auth: %s / %s" % [ config.proxy_user, config.proxy_pass ] end end puts "Open Timeout: %d seconds" % [ config.http_open_timeout ] puts "Read Timeout: %d seconds" % [ config.http_read_timeout ] if (config.recipient_override) puts "Recipient Override: %s" % [ config.recipient_override ] end puts "Environment: %s" % [ config.environment ] end desc 'Verify the PostageApp gem installation by requesting project info from the API' task test: :environment do diag = PostageApp::Diagnostics.new(PostageApp.config) puts "Resolving #{PostageApp.config.host.inspect}" if (resolved = diag.host_resolved) puts "\t#{resolved.join(',')}" else puts "\tCouldn't be resolved. [ERROR]" end if (PostageApp.config.proxy?) puts "Resolving #{PostageApp.config.proxy_host.inspect}" if (resolved = diag.proxy_host_resolved) puts "\t#{resolved.join(',')}" else puts "\tCouldn't be resolved. [ERROR]" end end puts "Trying to contact #{PostageApp.configuration.url}..." response = PostageApp::Request.new(:get_project_info).send if (response.ok?) project_name = response.data['project']['name'] project_url = response.data['project']['url'] user_emails = response.data['project']['users'] puts < Hello {{name}},

This is a html message generated by Postage plugin.

If you received this message it means that your application is properly configured and is ready to use PostageApp service.

Thank you,

The PostageApp Team

END TEXT_MESSAGE = < name } end PostageApp::Request.new( :send_message, message: { 'text/html' => HTML_MESSAGE, 'text/plain' => TEXT_MESSAGE }, recipients: recipients_with_variables, headers: { 'Subject' => '[PostageApp] Test Message', 'From' => 'no-return@postageapp.com' } ).send end