Getting Started with CfMailGun and Mailgun API - Looking for Implementation Help

I am attempting to use the CfMailGun library to send emails through the Mailgun API but I am facing some challenges. The documentation I found gives a general overview but lacks a comprehensive example.

It mentions the following initialization code:

mailService = new MailGunClient( apiKey = yourApiKey );

In my attempts to create a full implementation, I wrote this:

yourApiKey = "key-987654321";
mailService = new MailGunClient( apiKey = yourApiKey );

sendResult = mailService.sendMessage(
    domain = 'example.com', 
    from = '[email protected]', 
    to = '[email protected]', 
    subject = 'Test Email', 
    text = 'This is a test email', 
    html = '<strong>This is a test email</strong>'
);

However, I am encountering this error:

MailGun request failure. [‘from’ parameter is missing]

Does anyone have a successful implementation of this component? I would greatly appreciate a working example that details all required parameters and the correct setup.

The error message is misleading here - it says ‘from’ parameter is missing but your code clearly has it. This usually happens when the API endpoint format is incorrect. Make sure you’re using the full domain URL format for the domain parameter like ‘mg.yourdomain.com’ instead of just ‘example.com’. Also double-check that your API key starts with ‘key-’ and matches exactly what’s in your Mailgun account settings. I’ve seen cases where copying the key introduces hidden characters that break the authentication. Try logging the actual request being sent to see what parameters are really being passed to the API.

I ran into similar authentication issues when implementing CfMailGun recently. The root cause was actually the API endpoint configuration rather than missing parameters. You need to specify the correct Mailgun region in your client initialization - most people forget this step. If you’re using the EU region, add baseUrl = 'https://api.eu.mailgun.net' to your MailGunClient constructor. Also verify that your domain is fully activated in Mailgun console, not just added. Sometimes domains show as added but haven’t completed the DNS verification process yet. Try testing with a simple plain text email first without the HTML parameter to isolate the issue. The misleading error message often occurs when the API can’t properly parse the request due to endpoint mismatches.

had this exact same issue last week! the problem is your domain parameter - it needs to match your verified domain in mailgun dashboard. also check if your api key has the right permissions set. mine worked after fixing the domain mismatch.