Difference between revisions of "Mail tweaks on iPhone OS"

From lensowiki
Jump to: navigation, search
(Created page with 'Once, I had sent an email from an IMAP account on my iPhone. The message was sent fine, as the recipient then replied to it. On the iPhone, things seemed ok, as the message showe…')
 
(Preventing MobileMail from trying to stay open/autolaunching: Minor clarifications)
 
(5 intermediate revisions by one other user not shown)
Line 1: Line 1:
 +
On this page I describe some Mail-related iPhone OS tweaks. Note that they assume that (1) your device is already jailbroken, (2) you have installed OpenSSH to browse files on it, and (3) you have iPhone OS 3.0 or higher on your device. If that's not the case, please [http://blog.iphone-dev.org visit the official Dev team website] for instructions on how to jailbreak your device. Once that's done, open Cydia and install OpenSSH. '''''Please immediately [http://www.iphonefaq.org/archives/97721 change your root password] after you do this to prevent your device from being hijacked.''''' Once that's done, you will need an SFTP client for your computer to browse and transfer files. That is beyond the scope of this tutorial, so [http://www.google.com/search?q=browse%20files%20iphone%20openssh Google is your friend].
 +
 +
==Recovering offline, never-uploaded Mail messages==
 
Once, I had sent an email from an IMAP account on my iPhone. The message was sent fine, as the recipient then replied to it. On the iPhone, things seemed ok, as the message showed up in my Sent folder. ''However, the IMAP server itself had absolutely no awareness of the message.'' To rectify the problem, I attempted to move the message to a different folder. I tried the Inbox, Drafts, Inbox subfolders, etc. Nothing worked. The iPhone showed the message in the correct folder, but the server still had no knowledge of it. Not wanting to lose the message, I decided to explore the iPhone filesystem to see if I could recover the message somehow.
 
Once, I had sent an email from an IMAP account on my iPhone. The message was sent fine, as the recipient then replied to it. On the iPhone, things seemed ok, as the message showed up in my Sent folder. ''However, the IMAP server itself had absolutely no awareness of the message.'' To rectify the problem, I attempted to move the message to a different folder. I tried the Inbox, Drafts, Inbox subfolders, etc. Nothing worked. The iPhone showed the message in the correct folder, but the server still had no knowledge of it. Not wanting to lose the message, I decided to explore the iPhone filesystem to see if I could recover the message somehow.
 
These instructions assume that your device is already jailbroken and you have installed OpenSSH to browse files on it. If that's not the case, please [http://blog.iphone-dev.org visit the official Dev team website] for instructions on how to jailbreak your device. Once that's done, open Cydia and install OpenSSH. '''''Please immediately [http://www.iphonefaq.org/archives/97721 change your root password] after you do this to prevent your device from being hijacked.''''' Once that's done, you will need an SFTP client for your computer to browse and transfer files. That is beyond the scope of this tutorial, so [http://www.google.com/search?q=browse%20files%20iphone%20openssh Google is your friend].
 
  
 
To recover your message(s):
 
To recover your message(s):
Line 8: Line 9:
 
#*turn off auto-lock
 
#*turn off auto-lock
 
#*tap your screen every so often
 
#*tap your screen every so often
#*or install Insomnia
+
#*install Insomnia
#*(or just work very very quickly :))
+
#*plug your phone into some sort of power source (power adapter or USB port)
 +
#*(just work very very quickly :))
 
#Navigate to <tt>/private/var/mobile/Library/Mail</tt>
 
#Navigate to <tt>/private/var/mobile/Library/Mail</tt>
 
#Now open the folder corresponding to the email account from which you sent the message (should be self-evident)
 
#Now open the folder corresponding to the email account from which you sent the message (should be self-evident)
Line 17: Line 19:
  
 
Finally, use a desktop email client to import the recalcitrant message (the .eml files) into the correct folder. Once you've verified that the message is on the server, you can delete the copy inside .OfflineCache if you want. If you'd rather play safe, just leave it there – the message will show up twice in whatever folder it's in when viewing on the phone, but the only thing that really matters is what's on the server.
 
Finally, use a desktop email client to import the recalcitrant message (the .eml files) into the correct folder. Once you've verified that the message is on the server, you can delete the copy inside .OfflineCache if you want. If you'd rather play safe, just leave it there – the message will show up twice in whatever folder it's in when viewing on the phone, but the only thing that really matters is what's on the server.
 +
 +
==Preventing MobileMail from trying to stay open/autolaunching==
 +
With iPhone OS 3.0, Apple introduced a behavior into SpringBoard such that the MobilePhone (Phone) and MobileMail (Mail) apps try to always stay open. Respringing results in these apps quitting and then relaunching. Furthermore, if you start a memory-intensive app, Mail will most likely get kicked out ''but SpringBoard will attempt to relaunch it as soon as possible''. This becomes very annoying, especially if you are on EDGE and have many email accounts, as Mail refreshes all accounts on startup and brings the entire OS to a grinding halt.
 +
 +
Unlike most other applications, whose persistence/restarting behavior is controlled by [[w:launchd|launchd]], this behavior is actually coded inside SpringBoard itself; as a result, you can't simply edit a [[w:plist|plist]] file in <tt>/System/Library/LaunchDaemons</tt> to change this. However, as communicated by [http://code.google.com/u/gaizin/ ashikase] in an email posted on [http://xsellize.com/threads/53536-Annoying-MobileMail.app-Auto-Launch/page2#post256908 xsellize], running <tt>strings</tt> on the SpringBoard binary serves up these two gems:
 +
SBDisableMailAutoLaunch
 +
SBDisablePhoneRelaunch
 +
Now the problem is much easier. Here's what you need to do:
 +
#Connect to your device via SSH (see above) using a terminal – this is key, we need to run some commands and not just modify files
 +
#Enter <tt>launchctl unload /System/Library/LaunchDaemons/com.apple.SpringBoard.plist</tt> and hit enter
 +
#Your phone will now show the spinning circle in the middle; this is fine
 +
#Connect to your phone with an SFTP client
 +
#Open <tt>/private/var/mobile/Library/Preferences/com.apple.springboard.plist</tt> in a plist editor
 +
#To the root, add a key with name <tt>SBDisableMailAutoLaunch</tt>, type <tt>Boolean</tt>, value <tt>true</tt> (or checked, if using [[w:Property List Editor|Property List Editor]])
 +
#Save file and upload back to device
 +
#In the terminal, enter <tt>launchctl load /System/Library/LaunchDaemons/com.apple.SpringBoard.plist</tt> and hit enter
 +
#Marvel at the results!
 +
You'll notice (if you have [http://code.google.com/p/iphone-backgrounder/ backgrounder] installed and badges for Apple apps enabled) that the Phone app will start but Mail won't. Mission accomplished!
 +
 +
One important caveat: doing this will disable push email, as Mail needs to keep running for that to work, unfortunately. Mail will continue running after you switch to another app; however, if Mail is quit for whatever reason (using SBSettings, or due to low memory), it will '''not''' automatically reopen until you open it manually yourself. Scheduled email checking will also cease to take place when the app is no longer running.

Latest revision as of 02:56, 3 June 2010

On this page I describe some Mail-related iPhone OS tweaks. Note that they assume that (1) your device is already jailbroken, (2) you have installed OpenSSH to browse files on it, and (3) you have iPhone OS 3.0 or higher on your device. If that's not the case, please visit the official Dev team website for instructions on how to jailbreak your device. Once that's done, open Cydia and install OpenSSH. Please immediately change your root password after you do this to prevent your device from being hijacked. Once that's done, you will need an SFTP client for your computer to browse and transfer files. That is beyond the scope of this tutorial, so Google is your friend.

Recovering offline, never-uploaded Mail messages

Once, I had sent an email from an IMAP account on my iPhone. The message was sent fine, as the recipient then replied to it. On the iPhone, things seemed ok, as the message showed up in my Sent folder. However, the IMAP server itself had absolutely no awareness of the message. To rectify the problem, I attempted to move the message to a different folder. I tried the Inbox, Drafts, Inbox subfolders, etc. Nothing worked. The iPhone showed the message in the correct folder, but the server still had no knowledge of it. Not wanting to lose the message, I decided to explore the iPhone filesystem to see if I could recover the message somehow.

To recover your message(s):

  1. Connect to your device
  2. Note that to prevent your phone's wifi from shutting off and potentially interrupting the process, you'll need to either
    • turn off auto-lock
    • tap your screen every so often
    • install Insomnia
    • plug your phone into some sort of power source (power adapter or USB port)
    • (just work very very quickly :))
  3. Navigate to /private/var/mobile/Library/Mail
  4. Now open the folder corresponding to the email account from which you sent the message (should be self-evident)
  5. Open the .OfflineCache folder inside that. Note that you might need to turn on showing of hidden files in your SFTP client to see this folder in the first place

Now, inside this folder, you should see one or more files. Download all of the files to your computer and open them in any text editor to verify that they are what you are looking for. If so, append the .eml extension to them. Accept whatever warning your OS might throw up about changing/adding file extensions.

Finally, use a desktop email client to import the recalcitrant message (the .eml files) into the correct folder. Once you've verified that the message is on the server, you can delete the copy inside .OfflineCache if you want. If you'd rather play safe, just leave it there – the message will show up twice in whatever folder it's in when viewing on the phone, but the only thing that really matters is what's on the server.

Preventing MobileMail from trying to stay open/autolaunching

With iPhone OS 3.0, Apple introduced a behavior into SpringBoard such that the MobilePhone (Phone) and MobileMail (Mail) apps try to always stay open. Respringing results in these apps quitting and then relaunching. Furthermore, if you start a memory-intensive app, Mail will most likely get kicked out but SpringBoard will attempt to relaunch it as soon as possible. This becomes very annoying, especially if you are on EDGE and have many email accounts, as Mail refreshes all accounts on startup and brings the entire OS to a grinding halt.

Unlike most other applications, whose persistence/restarting behavior is controlled by launchd, this behavior is actually coded inside SpringBoard itself; as a result, you can't simply edit a plist file in /System/Library/LaunchDaemons to change this. However, as communicated by ashikase in an email posted on xsellize, running strings on the SpringBoard binary serves up these two gems:

SBDisableMailAutoLaunch
SBDisablePhoneRelaunch

Now the problem is much easier. Here's what you need to do:

  1. Connect to your device via SSH (see above) using a terminal – this is key, we need to run some commands and not just modify files
  2. Enter launchctl unload /System/Library/LaunchDaemons/com.apple.SpringBoard.plist and hit enter
  3. Your phone will now show the spinning circle in the middle; this is fine
  4. Connect to your phone with an SFTP client
  5. Open /private/var/mobile/Library/Preferences/com.apple.springboard.plist in a plist editor
  6. To the root, add a key with name SBDisableMailAutoLaunch, type Boolean, value true (or checked, if using Property List Editor)
  7. Save file and upload back to device
  8. In the terminal, enter launchctl load /System/Library/LaunchDaemons/com.apple.SpringBoard.plist and hit enter
  9. Marvel at the results!

You'll notice (if you have backgrounder installed and badges for Apple apps enabled) that the Phone app will start but Mail won't. Mission accomplished!

One important caveat: doing this will disable push email, as Mail needs to keep running for that to work, unfortunately. Mail will continue running after you switch to another app; however, if Mail is quit for whatever reason (using SBSettings, or due to low memory), it will not automatically reopen until you open it manually yourself. Scheduled email checking will also cease to take place when the app is no longer running.