Skip to content

Instantly share code, notes, and snippets.

@jenslukowski
Created September 14, 2012 20:29
Show Gist options
  • Save jenslukowski/3724559 to your computer and use it in GitHub Desktop.
Save jenslukowski/3724559 to your computer and use it in GitHub Desktop.
RubyMotion: MailCore
class AppDelegate
def application(application, didFinishLaunchingWithOptions:launchOptions)
msg = CTCoreMessage.alloc.init
msg.setTo(NSSet.setWithObject(CTCoreAddress.addressWithName("Someone", email:"someone@example.com")))
msg.setFrom(NSSet.setWithObject(CTCoreAddress.addressWithName("Watson", email:"watson1978@gmail.com")))
msg.setBody("This is a test message!")
msg.setSubject("This is a subject")
error = Pointer.new(:id)
ret = CTSMTPConnection.sendMessage(msg,
server:"smtp.gmail.com",
username:"xxxxxxxx@gmail.com",
password:"xxxxxxxx",
port:587,
useTLS:true,
useAuth:true,
error:error)
true
end
end
# -*- coding: utf-8 -*-
$:.unshift("/Library/RubyMotion/lib")
require 'motion/project'
Motion::Project::App.setup do |app|
# Use `rake config' to see complete project settings.
app.name = 'HelloMailCore'
# Configure MailCore
app.vendor_project('vendor/MailCore',
:xcode, :scheme => "MailCore iOS", :headers_dir => '.')
app.frameworks << "CFNetwork"
app.libs << "/usr/lib/libssl.dylib"
app.libs << "/usr/lib/libiconv.dylib"
app.libs << "/usr/lib/libsasl2.dylib"
app.libs << "/usr/lib/libcrypto.dylib"
end
@DougPuchalski
Copy link

This doesn't appear to work when building for the iOS device (rake device)

@mkdynamic
Copy link

@aceofspades That's because it's linking to static libraries on the Mac, and not the platform specific ones created by the Xcode build.

Took me a while to figure out the correct configuration, but eventually got it working:
https://gist.github.com/4425691

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment