Setting email header to objective-C?

I am trying to create an application that sends an email using MFMailComposeViewController , but this class does not seem to be able to set email headers.

I tried to find a lower level solution (or even a library) that does this, but cannot find it. How to set up / get email headers in Objective-C app?

[EDIT] To be clear, I am looking for a way to set email headers in ways other than MFMailComposeViewController. I already know how to send a simple email. I am looking for a way to set email headers such as In-Reply-To or Message-ID

+6
source share
3 answers

The authors of Sparrow created a great class called MailCore (now with version 2) that allows you to do just that.

If you go to class class documentation here: http://libmailcore.com/mailcore2/api/Classes/MCOMessageHeader.html

You can find all the useful headers in properties like messageID , inReplyTo , etc.

+1
source

If you want to create an email header, you can create your own custom header using html and set it as the body of an email message with isHTML as True.

I just tried the following code:

 NSString * Htmlstr =[NSString stringWithFormat:@ "<html>" "<body>" "<div id=\"container\" style=\"background-color:#EEEEEE;height:300px;width:500px;float:left;\">" "<div id=\"header\" style=\"background-color:#FFA500;\">" "<h3 style=\"margin-top:0;\">ABC</h3></div>" "<div id=\"content\" style=\"background-color:#EEEEEE;height:300px;width:500px;float:left;\">%@</div>" "<div id=\"Banner\" style=\"background-color:#EEEEEE;clear:both;text-align:left;margin-top:0;\"><img src=\"%@\" alt=\"Smiley face\" width=\"500\" height=\"100\"></div>" "<div id=\"footer\" style=\"background-color:#FFA500;clear:both;text-align:center;margin-bottom:0;\">Copyright © abc.com</div>" "</div>" "</body>" "</html>",emailBody,self.SelectedBannerImage]; 

[mailer setMessageBody: Htmlstr isHTML: YES];

Hope this helps you.

+1
source

I think you will have enough resources if you use the libcurl (c) library or one of its cocoa shells, no?

Check here BBHTTP and CURLHandle .

This will allow you to manually compose your smtp traffic using the cocoa / objc syntax. Does it look more like what you are looking for?

+1
source

Source: https://habr.com/ru/post/975813/


All Articles