typesafe / mnailgun

A simple .Net wrapper library for the Mailgun API that allows you to send messages, create web hooks, manage mailboxes, etc. with minimal effort.
Other
35 stars 25 forks source link

Need at least one of 'text' or 'html' parameters specified #14

Closed natiki closed 8 years ago

natiki commented 9 years ago

Hi,

Appreciate you making this available.

Been using this for almost a year without issue. I am now intermittently (through the same code path as far as I can tell) getting the exception as per the title.

As far as I can tell the mail message being passed to mnailgun is valid. Any ideas or pointers?

typesafe commented 9 years ago

Could you post some client code that reproduces the error?

natiki commented 9 years ago

Hi Gino,

Been able to track this down some more.... It appears that if we have body of a mail message either being string.Empty or contain spaces then we get the error.

     //aMailMessage is passed in and is a System.Net.Mail.MailMessage. It has IsHtml set to TRUE

    //Should the message body be empty then MailGun will return the error "Need at least one of 'text' or 'html'"
            //So we take care of this here as _MailGunClient does not appear to encapsulate this kind of body well either
            if (string.IsNullOrEmpty(aMailMessage.Body))
            {
                aMailMessage.Body = ".";
            }

Reason this is blowing up for me is that this is the first time a user managed to send an email message with no body (we normally append a system footer so that is why I have not seen this before).

typesafe commented 8 years ago

Hey Donovan,

(I realise this is ridiculously late, am catching up on a lot of things atm)

Since this is a MailMessage behaviour and mnailgun is not encapsulating it in any way (on the contrary). I'm afraid there's nothing precautionary that I could add to the lib, so I'll just close this issue.