May 27, 2009

How to use GMail’s SMTP Server with Merb

I switched our email service provider to Google last week. So I have to figure out how to send out emails with GMail. I started with the default Net::SMTP settings, but it failed miserable:

    ~ 530 5.7.0 Must issue a STARTTLS command first. 7sm1765038qwf.45

After playing a while and googled a bit, here is the solution:

1. In your dependencies.rb, add following line:
    dependency "tlsmail"
2. Install the gem
    bin/thor merb:gem:install
3. Modify your init.rb
   
4. Over write the mailer
   
    Note: the "Net::SMTP.enable_tls(OpenSSL::SSL::VERIFY_NONE)"
5. Sending email
   
    Note: use :text instead of :body

Now, you are good to go.


May 5, 2009

How to add a third-party framework in your iphone project

I was working on an iPhone project, which needs some other third-party frameworks which is developed in c++. Since I am new to XCode, it really took me a while to get it straight.

1. Hard copy the third-party's src code fold into your iPhone project.
2. In your iPhone project, create a new taget
3. Unfold your target, right click(or control click) on the new target, choose "add existing files", then find the src you just copied. Do NOT check "Copy items into destination group's folder", because you've already copied it.
4. Compile your new target, if every thing goes well you should be able to get the .a file.
5. Drag the .a file to your project target -> link binary with libraries folder.
6. This step is optional, it depends on what type the third party src is. If it is c++ src, you have to rename your file which make directly calls to the third-party from .m to .mm.

I am hoping this could save you sometime to get your iPhone project up and running.