objective c - Send email with attachments with Mailgun -


i'm integrating mailgun ios app, , trying send email attachment. email gets sent, attachment appears ignored. ideas? code below. i'm using afnetworking 2, , don't use the native mailgun objective-c sdk, since doesn't appear maintained.

nsstring *path = [nsstring stringwithformat:@"https://api:%@@api.mailgun.net/v3/%@/messages", ktixmailgunapikey, ktixmailgundomain];  afhttprequestoperationmanager *manager = [afhttprequestoperationmanager manager]; manager.responseserializer.acceptablecontenttypes = [nsset setwitharray:@[ @"text/plain", @"text/html", @"application/json" ] ];  nsdata *attachment = [attachments firstobject];  nsdictionary *parameters = @{                              @"from"            : fromaddress,                              @"to"              : toaddress,                              @"subject"         : @"inline",                              @"text"            : @"email body",                              @"content-type"    : @"multipart/form-data",                              @"attachment"      : attachment,                              }; [manager post:path    parameters:parameters       success:^(afhttprequestoperation *operation, id responseobject)  {      nslog(@"success sending message. response: %@", responseobject);  } failure:^(afhttprequestoperation *operation, nserror *error)  {      nslog(@"error sending message: %@", error);  }]; 

i able send attachments using curl, e.g.:

curl -s "https://api:key- [redacted]@api.mailgun.net/v3/sandbox[redacted].mailgun.org/messages" \ -f from=[redacted]@gmail.com \ -f to=[redacted]@gmail.com \ -f subject='check out!' \ -f text='lol' \ -f attachment=@"lolcat.png" 

it possible send attachments within ios application using mail gun:

mailgun *mailgun = [mailgun clientwithdomain:@"yourdomain.com" apikey:@"key"];  mgmessage *message = [mgmessage messagefrom:@"someone <your.address@yourdomain.com>"                                          to:@"someone else <someone@else.com>"                                     subject:@"hello"                                        body:@"this test email."];  [message addattachment:[nsdata datawithcontentsoffile:@"filepath"] withname:@"filename" type:@"filetype"];  [mailgun sendmessage:message success:^(nsstring *messageid) {     nslog(@"message %@ sent successfully!", messageid); } failure:^(nserror *error) {     nslog(@"error sending message. error was: %@", [error userinfo]); }]; 

Comments

Popular posts from this blog

android - MPAndroidChart - How to add Annotations or images to the chart -

javascript - Add class to another page attribute using URL id - Jquery -

firefox - Where is 'webgl.osmesalib' parameter? -