Does anyone have a code example of HTTPSecureSocket with MailGun API?

Sorry to be a pain, but I just can’t quite get my head round using HTTPSecureSocket to send a basic email via MailGun’s api. I know I’m being really dum, but just need to see an example so I can understand the process - DOH !!

What do you have so far? :slight_smile:

Not a lot really, but just starting here:-

[code] Dim vfrom As String = txtFrom.Text
Dim vdomain As String = txtMailDomain.Text
Dim vkey As String = txtKey.Text
Dim vto As String = txtRecipient.Text
Dim vsubject As String = txtSubject.Text
Dim vbody As String = txtBody.Text
Dim vURL As String = txtURL.Text
Dim vPost As String

MyHTTP = new HTTPSecureSocket
AddHandler MyHTTP.AuthenticationRequired, AddressOf AuthenticationRequired

vURL = vURL + vdomain
MyHTTP.Address = vURL
MyHTTP.Secure = True
MyHTTP.ConnectionType = 2

//Wait while connecting
loop until (myHTTP.IsConnected or (myHTTP.LastErrorCode <> 0))
if MyHTTP.IsConnected Then
vPost = vURL +"’’/messages’’"
self.MyHTTP.Post (vPost)
end if
txtError.Text = Format(MyHTTP.LastErrorCode,"#####")[/code]

Connectiontype 2 isn’t going to work these days. You must use one of the TLS variations.

Thanks Greg, understood.
But I have no idea if I am supposed to “myHTTP.Connect” and then myHTTP.Post - or do I just do the latter? Also have no idea how to authenticate the connection, or how to send over the email data in the Post command.

All very fuzzy in my brain! I’m sure it’s easy, once I understand the api concept…

You could also use Mailgun with SMTPSocket…

Yes, thanks Michel, I already do use SMTPSecureSocket - and yes it works fine, except Mailgun does not permit Batch sending via SMTP, they say I have to use their api - but I can’t get my head round how to use their api with Xojo… I’m probably just missing a simple step somewhere!