Create new IMAP & SMTP account with AppleScript

After reading a thread over here where some of you mentioned the problem creating a new mail account using AppleScript in fact there really seems to be a bug that doesn't allow to change authentication of a SMTP server to Password.
So I ended up going this way using PListbuddy. Of course this is no complete script and you have to adapt it to your needs. But in general "automatic" creation of new accounts works fine. We're using it to provide this to our customers as Apple Mail does not support automatic creation of mail accounts using autoconfig or autoresponder.xml.
set command1 to "/usr/libexec/PlistBuddy -c 'Add :DeliveryAccounts:0 dict' ~/Library/Preferences/com.apple.mail.plist"
set command9 to "/usr/libexec/PlistBuddy -c 'Add :DeliveryAccounts:0:AccountName string " & theMail & "' ~/Library/Preferences/com.apple.mail.plist"
set command2 to "/usr/libexec/PlistBuddy -c 'Add :DeliveryAccounts:0:AccountType string SMTPAccount' ~/Library/Preferences/com.apple.mail.plist"
set command3 to "/usr/libexec/PlistBuddy -c 'Add :DeliveryAccounts:0:Hostname string " & servername & "' ~/Library/Preferences/com.apple.mail.plist"
set command4 to "/usr/libexec/PlistBuddy -c 'Add :DeliveryAccounts:0:SSLEnabled string YES' ~/Library/Preferences/com.apple.mail.plist"
set command5 to "/usr/libexec/PlistBuddy -c 'Add :DeliveryAccounts:0:ShouldUseAuthentication string YES' ~/Library/Preferences/com.apple.mail.plist"
set command6 to "/usr/libexec/PlistBuddy -c 'Add :DeliveryAccounts:0:Username string " & username & "' ~/Library/Preferences/com.apple.mail.plist"
set command7 to "/usr/libexec/PlistBuddy -c 'Add :DeliveryAccounts:0:uniqueId string " & myid & "' ~/Library/Preferences/com.apple.mail.plist"
set command8 to "/usr/libexec/PlistBuddy -c 'Add :DeliveryAccounts:0:AuthenticationScheme string PASSWORD' ~/Library/Preferences/com.apple.mail.plist"
do shell script command1
do shell script command2
do shell script command3
do shell script command4
do shell script command5
do shell script command6
do shell script command7
do shell script command8
do shell script command9
tell application "Mail"
          set newimapac to make new imap account with properties {name:theDescription, user name:theUsername, uses ssl:true, server name:servername, port:"993", full name:theName, email addresses:{theMail}}
          tell newimapac
                    set authentication to password
                    set user name to username
                    set password to thePassword
          end tell
          set mysmtp to smtp server (theDescription)
          tell mysmtp
                    set password to mypass
          end tell
          set smtp server of newimapac to mysmtp
end tell

The following works exactly right, so far as I can tell (note that I made a copy of the Mail.app plist and renamed it
com.apple.mail_copy.plist). what are you doing differently?
set theMail to ""
set servername to ""
set myid to ""
set username to ""
set accountRecord to {AccountName:theMail, AccountType:"SMTPAccount", Hostname:servername, SSLEnabled:"YES", ShouldUseAuthentication:"YES", uniqueId:myid, |Username|:username, AuthenticationScheme:"PASSWORD"}
tell application "System Events"
          set theMailPlist to property list file "~/Library/Preferences/com.apple.mail_copy.plist"
          tell theMailPlist
                    tell property list item "DeliveryAccounts"
                              set newAccountItem to make new property list item at beginning with properties {kind:record, value:accountRecord}
                              tell newAccountItem
                                          make new property list item with properties {kind:string, name:"Username", value:username}
                              end tell
                    end tell
          end tell
end tell
to find a particular item in a list or directory, you use code like the following:
tell application "System Events"
          set theMailPlist to property list file "~/Library/Preferences/com.apple.mail_copy.plist"
          tell theMailPlist
                    tell property list item "DeliveryAccounts"
                              get every property list item whose (value of property list item "Username") contains "chump"
                    end tell
          end tell
end tell

Similar Messages

  • If I create a new Apple id account with the same bank details for a old Apple id account will I lose my old account?

    My daughter has created a Apple Id account with my bank details and I have an Apple id account myself on her phone it's comimg up with "This Device Is Already Associated With an Apple ID. If you turn on Automatic Downloads with your Apple ID, you cannot auto-download or download past purchases with a different Apple ID for 90 days."  Does this mean if she presses cancel or transfer will my account be affected in anyway.

    I set up FaceTime and Messages on four different devices with only one Apple ID. I used the exact method that is described in the video that AnaMusic has provided to you in the link in her response above.  That method worked fine for my family, but you can create new Apple ID's just to use for FaceTime and Messages if you like. Many users prefer doing that as opposed to adding new email addresses.
    IMO - using unique email addresses (like in the video) makes sense, because we (my family) all have different email addresses anyway, and it was very simple to add each family members email address to both apps and remove my Apple ID email address as the contact address on each device.
    BTW .... if you are using your Apple ID on both devices - your phone number should be the number that is showing in the settings - not you daughter's. Did you set up the Apps with your Apple ID?

  • HT3376 i need to add a new imap mail account and Mail automatically creates a pop one. what should I do? thank you

    I need to create a new imap mail account in Mail and the program automatically creates a pop one.
    What should I do?
    Thank you for your help.
    Arolla

    Hello, on about the second step, it doesn't give you a choice of POP, IMAP, or Exchange? Or does it change it to POP if you choose IMAP anyway?
    Who is your eMail provider, the part after the @ sign?

  • HT201320 Does my email service provider have to provide the ability for me to create an IMAP email account in order for me to create Sub-folders within Apple Mail?

    Hi, Apple Mail provides a function to create sub-folders within my mailbox so that I can group emails of similar subjects or from the same sender. My service provider only provides POP email protocol and the New Folder button does not appear in my Apple Mail account for that service provider. Icloud provides the opportunity for the iPad user to select between POP and IMAP. I can select IMAP and the New Folder button appears allowing me to create sub-folders within the icloud email account. Does this mean I cannot create sub-folders in my email account unless my service provider provides customers with the option of creating an IMAP email account?
    This appears to be a problem for quite a few Apple Mail users, but service providers appear reticent to provide a response other than 'use Microsoft Exchange / Hotmail, Google GMail, or some other third party email service provider'. This is why I have chosen icloud as my email service provider. It is Apple and therefore Apple supports it. I have been a Telstra customer for over 15 years and they informed me today, strongly, that they support their own products and services, not Apple products, even though Telstra sell them. When I asked the Telstra Customer Support Manager whether they support Telstra customers, I was informed 'no, because the Telstra customer is not a Telstra product or service'. I have since cancelled my Telstra email account and am in the process of cancelling all of my Telstra services.

    Apple Sceptic wrote:
    Does this mean I cannot create sub-folders in my email account unless my service provider provides customers with the option of creating an IMAP email account?
    Yes. That is what it means. You need an IMAP account in order to create sub folders on the iPad.

  • How to create new view without interlinking with gantt chart or resource views

    ok clear
    one another question
       In msp how to create new view without interlinking with gantt chart or resource views

    Hi Shiv PMC--
    I splitted your question above in another thread in order not to have  a huge thread with many topics in it.
    That being said, I'm not sure to understand. A view is just a manner to display MS Project data with columns. A view can have a table with column (left part) associated with a Gantt chart. It can also just contain a table with no Gantt chart (like the task
    table) or a table with a timephased grid (resource and task usage).
    Please give us more information, maybe with a concrete example so we can help you.
    Hope this helps,
    Guillaume Rouyre, MBA, MVP, P-Seller |

  • How Create New Folder in KM with Name having Special Character

    Hi,
    How to create new Folder in KM with name having special character in it.
    Right now its not allowing me to create folder when i have Colon( as one of the character in name of the folder.
    Is there a way to change this validate?
    Any help is appriciated.
    Thanks

    Hi DK,
    I'm not sure about special chars such as ":" but ifyou need to have your folders displaying special language chars (like german chars), have a look into the below link.
    https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/30deb229-d570-2910-4aaf-8858e0660f05
    Hope that helps.
    Ray

  • Create new InContext Editing accounts functionality unavailable starting Saturday Oct 31 at 7pm PDT until Sunday Nov 1 at noon PST

    The Adobe InContext Editing service will undergo scheduled maintenance starting on Saturday Oct 31 at 7pm PDT and end Sunday Nov 1 at noon PST. However, the service will be available during this time. The only area affected by this outage will be the new account creation. During this time, you won’t be able to create new InContext Editing accounts.
    We appreciate your patience and apologize for any inconvenience this may cause.
    -The Adobe InContext Editing Team

    This really should have gone out in an email to InContext users.  Not a huge deal, but I spent 20 minutes testing a site in various browsers, and looking on forums before i found this . . .
    Just an idea.
    Thanks.
    _T

  • Create two different iCloud accounts with 2 iPhones (family plan)?

    How do I create two different iCloud accounts with 2 iPhones (family plan). Both phones are registered under my name, and when my wife set up her phone with iOS 5, it will only let her log in using my account. I thought it used your iTunes account info, is this not the case?  I really want her to have her own seperate account on her phone.
    --Brian

    I resolved it by using our seperate apple ID's. Since we already had our own itunes accounts I canceled iCloud on her phone that was using my account and logged in with hers.  I did read somewhere where you can have multiple iCloud accounts under the same user ID but I'm not sure how that works because that is exactly how ours were set up initially and all the suddon all of her contacts and calendar items were on my phone and iPad and vica-versa . It was a pain to remove them one at a time after I broke the accoutns apart.  I know that doesn;t really answer your question, but that was my workaround. Of course that also mean no app sharing.

  • Create New Creative Cloud account to "rent" apps with

    My original account, this one has been compromised back in the great Adobe account pwning.
    So is it possible to create a different account from one of my co-workers, whos account was not pwned,
    in order to run Adobe Premiere Pro?
    Any every time I try to load Creative Cloud it asks to log in as me, and I want the following to
    happen.
    1) log in as the new account with credit card info
    2) Not attempting to log in as me, as my account was pwned.
    I even deleted CC earlier off my brand new machine and it insists on remembering my account, which I do not want
    to connect to a credit car due to the pwning.
    Will check in Monday for complete resolution.
    Thanks
    Message was edited by: Mark Pigott

    This is an open forum, not Adobe support... you need Adobe staff to help
    Adobe contact information - http://helpx.adobe.com/contact.html
    -Select your product and what you need help with
    -Click on the blue box "Still need help? Contact us"

  • How can I create a new game enter account with the same iTunes account

    I Created a separate gamec enter account for my two sons, I'd like to create one for my wife but I can't find a way to do it under ios8 can somebody help? Thanks

    Go to the System Preferences>Users.
    Click the lock if and enter your password, if necessary.
    Then click on the "+" symbol below the accounts list.
    From the "New Account" menu, select"Administrator" and fill in the rest of the information.
    And finally click the "Create Account" button.
    Done. A new Administrator user account.

  • Add a new IMAP Mail Account

    Hello there,
    I am trying to add a new IMAP account to my Outlook but strangely if the system is doing the Tests it sticks at the first one - The Log onto incoming mail server (IMAP). The problem it keeps up prompting asking again and again for my credentials. 
    Ia sure that my credentials are right.
    I already deleted my Profile and created a new one but the Problem keeps there. I already have other IMAP Mail adresses at with them its working all fine. Furthermore it works to create the account on a different Client such as Thunderbird.
    Any suggestions?!

    Hello,
    If the credential is correct, then it should be a confirguration issue. Have you clicked the "More settings..." button and set the correct port for Outgoing server (SMTP)? You might need to check with your ISP for the settings
    and make sure you have entered them correctly in "More settings" dialog.
    Another workaround that worth a try is go to Control Panel\All Control Panel Items\Credential Manager, then
    delete all the items listed under "Generic Credentials". Just pressing the down arrow button off to the right and then click "Remove".
    Hope this helps. Please have a try and feel free to post back.
    Thanks,
    Ethan Hua CHN
    TechNet Community Support

  • HT2534 How do you create an apple ID account with no credit card. HELP!!!

    There is no 'none' button for selecting a method payment when creating an apple ID account. HELP!!!

    Did you follow, exactly, the instructions on the HT2534 page that you posted from when creating the account ? I've just tried those instructions and got the 'none' option on a new account
    You could see if this post by mountaingoatgirl lets you review that account without needing to enter credit card details : https://discussions.apple.com/message/24303054
    If not, and if you don't want to enter credit card details (you should be able to remove them after entering them) then you will need to create a new account, using the instructions on the HT2534 page when creating it. If you want to use the same email address then you will need to replace it on that account first e.g. via the Store > View Account menu option on your computer's iTunes or via http://appleid.apple.com
    Creating an account with 'none' on a computer's iTunes : https://discussions.apple.com/message/24321860

  • Error while trying to create new calendar to sync with google calendar

    Hello everybody!
    I successfully syncronized my google calendar account with my iCal and everything works fine when I create or delete events.
    But when I try to create from iCal a new shared calendar it says "Calendar https://www.google.com/calendar/dav/[email protected]/user/ was not found on the server."
    Anyone has any idea about how to solve that?

    Hello everybody!
    I successfully syncronized my google calendar account with my iCal and everything works fine when I create or delete events.
    But when I try to create from iCal a new shared calendar it says "Calendar https://www.google.com/calendar/dav/[email protected]/user/ was not found on the server."
    Anyone has any idea about how to solve that?

  • Lost progress in game center account after re-create new apple id account by same email

    My situation is that my apple id was locked (I have no idea why) but I failed when tried to unlock it by Send Email Authentication or Answer Secure question (I noted the questions & answers before, then I'm quite sure I have correct stuffs), no idea why it didn't work.
    At that time, I did a silly action that I created a new apple id with the same email address (I had thought that it had to be impossible because Apple ID don't allow to create apple id with an unavailable email address and my apple id was just locked, not deleted or changed email). Unfortunately, I could create a new apple id with the same email address of the old one, why it's possible
    Then, the new apple id (same email address, same id, even same password ) but all my stuffs on icloud, progress on game center was replaced by EMPTY . hjx, I have a Clash Of Clan account with level 113, I contacted Clash Of Clan admin, they replied that they just could help me to do any necessary query to support if apple require, but they could not restore my progress to the new apple id (new but old)
    I appreciate for any recommendation to help me get my stuff back.
    Thanks for reading!

    I was able to correct this by going into Safari privacy settings and changing the accept cookies from Never to only visited.

  • Create new system and client with TDMS

    Hi all;
    I am tested the TDMS product with good results. I want create a new system and do one copy with time reduction time for new development system
    What it´s the best solution?
    - Install new system and do the client copy with TDMS
    or
    - System copy of production system, delete production client, create new client with UCUSV of productive system and copy client with TDMS?
    Thanks a lot

    Hi;
    It´s true :).
    Ok, one example, I have two systems, I want create system shell from A (client 900) to B . The central system is C
    In system B I don´t have any client but the Cross is diferent to system A
    I select in TDMS - ERP Shell Creation Package for SAP Release higher 4.6C
    System Definition;
    - Control system - C (all information it´s correct)
    - Sender system - A (Client 900)
    But i dont have any information about the receive system (A).
    When execute the synchronization appears the system A, but with any information (destination ID)
    and I have the error: Could not change password of RFC Destination sender system
    Any Idea
    thanks a lot for the help

Maybe you are looking for

  • Extraction of purchase order condition data

    Hello all- I do see that SAP has delievered the 2LIS_11_VAKON infosource which as by sales order the conditions within that sales order per item.  However, I need to get similar information from the purchasing side.  Ideally, I would like to get by p

  • Update the scrollbars of a JScrollPane

    Hi, I have a component in a JScrollPane. But when it changes its preferredSize the scrollbars of JScrollPane aren't updated automatically. I've tried: myComponent.getParent().repaint(); // JViewPort myComponent.getParent().getParent().repaint(); // J

  • Upgraded 3GS to 6.0.1 now will not read SIM card

    I tried to update 3GS to the new 6.0.1 but it now says the there is no SIM card and it can not be activated.

  • Need help with the "back up" on my iTunes/iPhone.

    Okay. I need a little help. I'm trying to download the newest version on the software onto my iPhone 3GS. But it keeps telling me that the back up is corrupt/damaged. I've deleted the backup from iTunes & none are currently showing up. But when I try

  • Distinct Records Selection in Crystal 11

    Need to select Distinct Records only, but the drop down under 'Database' shows the 'Select Distinct Records' option grayed out.  Why does Crystal do that, and how may I eliminate duplicate records?  Thanks!