Two objective-C email sending and receiving Codes

Source: Internet
Author: User

Http://www.cocoachina.com/macdev/cocoa/2009/0611/255.html

 

Some readers mentioned the need to develop email programs on the iPhone a few days ago. In addition to sending emails using mailto, there are no other better methods in the iPhone SDK.

Here we will introduce two open source email codes based on objective-C. In theory, the code can be used in the iPhone after minor modifications, but note that the authorization methods of these two codes are important.

 

Pantomime

Is a complete framework for developing mail programs, and many Mac-based desktop programs use this framework. In terms of functions, it supports MIME encoding and decoding, fully supports IMAP and POP3 protocols, and supports sending local emails or sending via remote SMTP. It supports SSL/TLS secure sending and receiving mechanisms.

Most of its code is written in objective-C. Only a small part of the code that requires performance is written in C. In addition, it uses a little EML.

Code. It can be used for both Mac OSX and gnustep compiling.

Pantomime is very simple to use, and the download package also provides a complete example of use, only a short amount of code can be used to receive, send, password verification and other functions.

If you want to develop a complete email program, pantomime is the best choice. Here

The version is 1.2.0pre3.

The name of another code is mailcore framework.

Developed by Matt Ronge (I feel that many people who develop Mac are called Matt ......). It is also very easy to use and comes with two simple and clear examples.

Sending emails using mailcore framework is very simple:

 

  1. Ctcoremessage *
    Testmsg =
    [
    [

    Ctcoremessage alloc

    ]

    Init

    ]

    ;
  2. [

    Testmsg setto:
    [

    Nsset

    Setwithobject

    :
    [

    Ctcoreaddress addresswithname:
    @ "Monkey"

    Email:
    @ Monkey@monkey.com"

    ]
    ]
    ]

    ;
  3. [

    Testmsg setfrom:
    [

    Nsset

    Setwithobject

    :
    [

    Ctcoreaddress addresswithname:
    @ "Someone"

    Email:
    @ Test@someone.com"

    ]
    ]
    ]

    ;
  4. [

    Testmsg setbody:
    @ "This Is A Test message! "

    ]

    ;
  5. [

    Testmsg setsubject:
    @ "This is a subject"

    ]

    ;

After setting, you can directly send the message:

  1. Ctsmtpconnection sendmessage:
    Testmsg Server

    :
    @ "Mail.test.com"

    Username:
    @ "Test"

    Password

    :
    @ "Test"

    Port

    :
    25

    Usetls:
    Yes

    Shouldauth:
    Yes

    ]

    ;
  2. [

    Testmsg release

    ]

    ;

Note that mailcore does not support multithreading. In addition, mailcore stores all information in the memory, so developers need to manually Save the code. However, it is still a very simple and easy-to-use email receiving and sending Code. It is recommended that you take a look at it.

Here is mailcore.

Including documents and examples.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.