Jump to content

dhjdhj

Member
  • Posts

    43
  • Joined

  • Last visited

Everything posted by dhjdhj

  1. I don't understand the complexity of RunCommand Why can't you just have a /bin/bash script block whose first line contains {query} Then if you have a keyword 't' you can just type things like t date or t ls /Applications | grep -i photo Seems to work fine ---
  2. I'm regret I'm not in a position to teach Python right now (sorry) but you certainly don't change the port in an import statement so dump those parentheses and make that line back to from smtplib import SMTP_SSL as SMTP (Note, that I have not tested this with SSL support) The port is set when you create the connection, which is on line 46 of my code theConnection = SMTP(smtpServer,26) However, if you have to use SSL, then you might have to deal with certificates (typically you will just want to ignore them). There's an example on stackexchange that might help you http://stackoverflow.com/questions/64505/sending-mail-from-python-using-smtp However, be aware that python3 (which I used) has slightly different syntax from the older python2 Sorry I can't help you completely troubleshoot this.
  3. Unfortunately, there are various different options depending on what server you're trying to connect to, what ports are opened by your ISP and so forth. Here's the link for the SMTP class https://docs.python.org/2/library/smtplib.html and here are the settings that icloud seems to want http://support.apple.com/kb/ht4864
  4. I'm the one who wrote the script at deskew.com and just noticed this discussion thanks to someone emailing me yesterday. So a couple of observations. First of all, thanks for noticing the permissions issue. I forgot to mention that and have updated my blog entry accordingly. Easy to forget that such things are not obvious to users who don't do command line stuff a lot. You're also correct that it requires Python 3 and I've added into to the blog as to where to get it. Like Apple, I like to use the latest and greatest rather than legacy stuff :-) While smptServer rather than smtpServer (Simple Mail Transfer Protocol, for anyone who cares) is certainly a typo, it's a variable name and the same variable name is used everywhere, therefore the typo has ZERO semantic impact on the behavior of the program, so it isn't an "issue", no matter how trivial. Wanted to clear that up just in case someone thinks it is in fact an issue. You're correct that password is plain text. But it's in a file you control on your own machine. The password that goes out to the server is encrypted and that's really all that matters. However, most importantly, I find that the ability to send quick emails to a few of my friends (and my wife) by simply typing their name and a message directly into Alfred to be extremely productive. I can be in the middle of working on any project (development, writing, music, whatever) and it is not neccessary to switch away from that activity to open your mail program and fill in all the fields just to send a quick message. I think that once you try it, it becomes a key utility that does not interrupt your workflow. Clearly lots of ways to make this better -- I tried to figure out how to grab the email address directly from contacts so that I wouldn't be restricted to just a few people. I forget now why I wasn't able to do it but it's low priority at this point.
  5. It seems to be difficult (if not impossible) to get xcode to see external environment variables if you just open xcode the normal way. In other words, it doesn't seem to pick up stuff from environment.plist etc So I created a simple shell script that sets the variables I need and then opens xcode and sure enough, the environment variables I set (as well as others that were set through my .bashrc) are available. So then I thought I'd try and do this through Alfred since it has the ability to invoke a script. However, when I trigger a "Run Script" that just the shell script I created, the environment variable is no longer visible from Xcode. Any ideas?
  6. I have a useful workflow that makes it easy to send a quick message by email to someone from within Alfred. Very handy when the phone rings and you have to let your better half know they got a call. The steps to create it are described in my blog. You will need to install python3. http://deskew.com/blog/?p=179
  7. Yeah, that's what I've been doing....I guess I was looking for a better way --- the trouble with that approach is you have to a) discover that you can't find an app then go figure out where it really lives and c) add the original folder. As more and more programs do this kind of installation, it becomes a messy solution. Curious as to why Alfred can't see and resolve aliases in the Applications folder
  8. OK --- I've discovered that this problem is happening because aliases are not being found --- spotlight is not finding them either ---- and a cursory google search would indicate that spotlight can't find them --- that's a pain. Any workarounds?
  9. Whose metadata? For example, spotlight had no problem finding the application even though Alfred couldn't find it.
  10. That worked, thank you. But I'm wondering why it was necessary to do this?
  11. A lot of apps now seem to place themselves in folders that they put inside Applications. Those apps aren't findable since (as far as I can tell) Alfred doesn't search Applications recursively. I thought this used to work but perhaps I'm mistaken. Anyway, I couldn't find any way to enable recursive search. Is this doable?
  12. OK --- I created a python script (called quickmessage.py) that can be invoked directly from Alfred. You need Python3 installed on your Mac. The script is below. Adjust it to suit your own server settings, etc You can invoke it from Alfred using the /bin/bash object with the following argument. /path/to/quickmessage.py -r <sender email address> -s <subject> -m {query} So I typically create different workflows with the desired sender email address and subject hard coded. I would still like to know how I can invoke this from Alfred but using a contact name instead of an email address so that I can just use a single workflow for everyone. ------Python script below------ #!/usr/bin/env python3 #Edit these for your own server smptServer = 'your mail server here' sender = 'your own email address here' username = "your username here" password = "your password here" import sys import argparse from smtplib import SMTP # use this for standard SMTP protocol (port 25, no encryption) from email.mime.text import MIMEText parser = argparse.ArgumentParser(usage = "echo <content> | quickmessage -s <subject> -r <recipient>" ) parser.add_argument("-r", "--recipient", required = True, help = "Email address of person to whom you want to send the message") parser.add_argument("-s", "--subject", required = True, help = "Subject line of the message") parser.add_argument("-m", "--message", required = True, help = "The contents of the message you want to send") args = parser.parse_args() subject = args.subject recipient = args.recipient body = args.message try: theMessage = MIMEText(body, "plain") theMessage['Subject'] = subject theMessage['From'] = sender # some SMTP servers will do this automatically, not all theConnection = SMTP(smptServer) theConnection.set_debuglevel(False) theConnection.login(username, password) try: theConnection.sendmail(sender, recipient, theMessage.as_string()) print ("Mail sent") #Show this in notification center if you want finally: theConnection.close() except Exception as e: print ( "Unable to send email message: " + str(e) ) sys.exit( "Unable to send email message: " + str(e) )
  13. @ctwise I'm familar with the mailto: syntax. That's not the issue. The question is how do I retrieve (via Alfred) the email address from a contact so that I can pass the email address to my shell script? @sweens I'm using the mailx command on a linux server (so my Mac invokes ssh to access it). Unfortunately the Mac version of mailx doesn't seem to support the -A command and it was quicker to just ssh than to write a local python (say) script to send the mail. I'll probably do that eventually but since I always have a linux server around, I'm not rushed (sorry)
  14. I had built a useful workflow where I could type a specific code followed by arbitrary text and that text would be mailed to an email address associated with the code. This makes it really easy to send a quick message to someone without actually having to switch contexts to the email program. I'm essentially invoking command line email via a shell script to do this. However, it only works for the three or four names that I have predefined in separate workflows. I was looking at how you can invoke the email program by selecting someone's name from contacts and I'm wondering how I could select a contact but explicitly invoke my own command line email, so that I could use my shell script to send a quick email to an arbitrary person
×
×
  • Create New...