Welcome, Guest. Please Login
Tinderbox
  News:
IMPORTANT MESSAGE! This forum has now been replaced by a new forum at http://forum.eastgate.com and no further posting or member registration is allowed. The forum is still accessible via read-only access for reference purposes. If you wish to discuss content here, please use the new forum. N.B. - posting in the new forum requires a fresh registration in the new forum (sorry - member data can't be ported).
  HomeHelpSearchLogin  
 
Pages: 1 2 
Send Topic Print
Sending an email (Read 17539 times)
Graeme
Full Member
*
Offline



Posts: 6

Sending an email
Jan 14th, 2010, 3:57pm
 
I am a total newbie to Tinderbox and would like to send some simple email messages on the DueDate. The excellent article on email and Twitter leaves me a little confused. Is there a simple example (snippet) that demonstrates how I assemble the code from the article? I understand most concepts, but not all.
Back to top
 
 
  IP Logged
Mark Anderson
YaBB Administrator
*
Offline

User - not staff!

Posts: 5689
Southsea, UK
Re: Sending an email
Reply #1 - Jan 14th, 2010, 5:27pm
 
Where are you getting lost? With this osrt of thing, it can help to work backwards. For instance, can you figure out the command line you need TB to assemble for you? From that you can work out what parts can come from specific existing attributes, such as $Email, user attributes you might need to make and what is effectively boilerplate for the task.

So, consider the tutorial example. We're trying to make TB pass out a command line like:

sendmail -f kate@example.com fred@example.com, "Subject: todo: Submit paper"

In other words asking OS X's Unix shell: "please sendmail app, make a new email from kate@example.com to fred@example.com with the subject "todo: Submit paper" and send it.

Change the second addresses in the last code example to an address you can receive. Then you should be able to paste the code into Terminal, hit the return key and check an email gets sent - and received. Note, the email is not sent by your normal Email app (Mail, Entourage, etc.) but it's done under the hood. If the proces works, that's your first confidence builder - i.e. if you can get the command line right you know your Mac will send the mail you expected. If it doesn't aim to make the command line code work before trying anything in TB.

Assuming the above text worked, let's make that mail get send by a container note when we add a new note or drop a note into it. Try this OnAdd code (note the white space, single and double quotes need to be used as written):

$Result=runCommand('sendmail -f '+$Email(Kate Smith)+' '+$Email(parent)+', "Subject: todo: '+$Name+'"');

We use single and double quotes as we need to emit a quoted section in the email command line. If we want to emit double quotes, use sinlge quotes to make up the TB action code - or vice versa.

n the Email attribute of your container, add your own email address (or a target email address you can access for testing - ideally we want the mail to travel off your Mac to another computer before being read). Now make a new note called Kate Smith (you can customise this part later - once you understand the process) and in its Email attribute put the address kate@example.com).

Now make a note called 'Submit paper' (without the quotes!). Drop it into your container - you should get an email from Kate. It's a bare bones email, but you're on your way.

I can't test this fully right now as my Mac failing test #1 - it won't email from the command line!
Back to top
 
 

--
Mark Anderson
TB user and Wiki Gardener
aTbRef v6
(TB consulting - email me)
WWW shoantel   IP Logged
Mark Anderson
YaBB Administrator
*
Offline

User - not staff!

Posts: 5689
Southsea, UK
Re: Sending an email
Reply #2 - Jan 14th, 2010, 7:01pm
 
FWIW, I seem to be able to send email using:
printf "Subject: Test\nHello" | sendmail -f you@domain.com you@domain.com
whereas the syntax in the last post doesn't work OMM. Probably some Unix permissions thing.

Anyway, I've done a demo for you: sendmail.tbx. (If the file loads as text in your browser, just do a 'save as' and save to your Mac as 'sendmail.tbx'.). DON'T FORGET - set your email in the $Email of the sending container.

Back to top
 
 

--
Mark Anderson
TB user and Wiki Gardener
aTbRef v6
(TB consulting - email me)
WWW shoantel   IP Logged
Graeme
Full Member
*
Offline



Posts: 6

Re: Sending an email
Reply #3 - Jan 15th, 2010, 2:49am
 
Hi Mark,

Almost but not quite - I can't persuade your revised terminal instruction to work - it says that it runs but that there is a missing format character after "Subject:  My C is rusty so I can't remember what it should be.  

Regards,

Graeme
Back to top
 
 
  IP Logged
Mark Anderson
YaBB Administrator
*
Offline

User - not staff!

Posts: 5689
Southsea, UK
Re: Sending an email
Reply #4 - Jan 15th, 2010, 4:02am
 
It runs here (I'm on 10.5.8 FWIW). Did you change anything other than the email address in your first test? If you did, download a fresh copy and start over.  Do that very simple check before attempting enhancements.  Does the basic test work for you, i.e. dropping the 'Submit paper' note?
Back to top
 
 

--
Mark Anderson
TB user and Wiki Gardener
aTbRef v6
(TB consulting - email me)
WWW shoantel   IP Logged
Graeme
Full Member
*
Offline



Posts: 6

Re: Sending an email
Reply #5 - Jan 15th, 2010, 4:41am
 
I have returned to your original idea with Terminal and I cannot get your revised command line to work - it still says "format character missing" from your printf statement.  I assume that the | character is still AND (&&). My OS is 10.6.2 but that shouldn't make any difference.
Back to top
 
 
  IP Logged
Mark Anderson
YaBB Administrator
*
Offline

User - not staff!

Posts: 5689
Southsea, UK
Re: Sending an email
Reply #6 - Jan 15th, 2010, 6:02am
 
No the '|' ('pipe' character) should be left as it is. If I substitute one of my email addresses for 'me@domain.com', the following works here:

printf "Subject: Test\nHello" | sendmail -f you@domain.com me@domain.com

The 'to' address I use only gets read on one of my PCs so it's definitely leaving the Mac.

Can you please paste into a post here the command line that is failing in your Terminal?
Back to top
 
 

--
Mark Anderson
TB user and Wiki Gardener
aTbRef v6
(TB consulting - email me)
WWW shoantel   IP Logged
Graeme
Full Member
*
Offline



Posts: 6

Re: Sending an email
Reply #7 - Jan 15th, 2010, 6:33am
 
This is the line that I used in Terminal:

printf "Test\nHello" | sendmail -f gforrestb@mac.com gforrestb@mac.com
Back to top
 
 
  IP Logged
Mark Anderson
YaBB Administrator
*
Offline

User - not staff!

Posts: 5689
Southsea, UK
Re: Sending an email
Reply #8 - Jan 15th, 2010, 6:58am
 
Well I put thin in my Terminal:
printf "Test\nHello\nFrom\Mark" | sendmail -f mwra@mac.com gforrestb@mac.com

It appeared to send here, so if you get a message it's proof it works here. [just got it]

Part of the problem here is the Unix shell/command line that isn't really designed/documented for use by ordinary folk (i.e. non-Unix-experts). Anyhow, at present the problem isn't Tinderbox. Until you can send an email from your Mac's Terminal there's no point trying it from Tinderbox.  It looks as if you need help with the Unix/sendmail aspect, which is sadly outside my area of expertise.
Back to top
 
 

--
Mark Anderson
TB user and Wiki Gardener
aTbRef v6
(TB consulting - email me)
WWW shoantel   IP Logged
Graeme
Full Member
*
Offline



Posts: 6

Re: Sending an email
Reply #9 - Jan 15th, 2010, 7:05am
 
Mark - Terminal seemed to work correctly then - did you receive it?  I will stop annoying you now and see if I can put everything together.

Thanks for your patient help.
Back to top
 
 
  IP Logged
Mark Anderson
YaBB Administrator
*
Offline

User - not staff!

Posts: 5689
Southsea, UK
Re: Sending an email
Reply #10 - Jan 15th, 2010, 7:14am
 
Got your reply OK - but I assume that came from an email client like Mail or Entourage. The problem with Unix stuff is it's something of a members/experts-only club; if you need help you're adjudged too dumb to play. Sad, but seemingly so. I've had little joy with web articles but (a few) folk in the Apple discussion boards were helpful. There's no group specifcally for Unix stuff so try one of the groups in the "Mac OS X & Related Software" heading, here.

One issue I'm seeing with by current Leopard MBP which I didn't see on my old tiger system is that I get mail from Terminal or TB but in my mail client it shows up as addressed to "undisclosed-recipients:". I've tracked this down to an under-the-hood security setting I can't (and probably shouldn't change).

I'm sure the TB community does include a few with Unix expertise but I guess their too expert to ever think of visiting the forums!
Back to top
 
 

--
Mark Anderson
TB user and Wiki Gardener
aTbRef v6
(TB consulting - email me)
WWW shoantel   IP Logged
Graeme
Full Member
*
Offline



Posts: 6

Re: Sending an email
Reply #11 - Jan 15th, 2010, 7:20am
 
Thanks again - I shall try and find some help as you suggest.  For the moment I have plenty to learn with TB so will concentrate on this first and return to email later.  Maybe you could build it in?  Thanks.
Back to top
 
 
  IP Logged
Derek Van Ittersum
Full Member
*
Offline



Posts: 168

Re: Sending an email
Reply #12 - Jan 19th, 2010, 4:29pm
 
I would also like to email out of Tinderbox, but am getting stuck with the command.  I've got the Unix figured out, mostly, and the HTML templates are producing what I want.  But, I can't figure out what action code to write in order to make TBX email me some notes.

Here's what I can do in the terminal:

printf "Message" | mail derek@example.com

sends me an email with "message" in the body

I have a container note with two agents in it, with HTML templates set for each.  How can I use those templates to produce a message and then get that message sent to me using the above UNIX code?  I'm way out of my depth here, but feel like I'm close to making it happen . . .
Back to top
 
 
  IP Logged
Mark Anderson
YaBB Administrator
*
Offline

User - not staff!

Posts: 5689
Southsea, UK
Re: Sending an email
Reply #13 - Jan 19th, 2010, 5:04pm
 
OK your start is:

  printf "Message" | mail derek@example.com

The green bits are static - unchanging text while the rest we'll pull from some attribute.  Also worth noting, the green text includes some double quotes.  We can't escape quotes in TB, so we'll build the runCommand with single quotes (in red in the example below).

  runCommand('printf "'+$MyMessage+'" | mail '+MyEmail)

Or without the colouring:

  runCommand('printf "'+$MyMessage+'" | mail '+MyEmail)

Does that help?
Back to top
 
 

--
Mark Anderson
TB user and Wiki Gardener
aTbRef v6
(TB consulting - email me)
WWW shoantel   IP Logged
Derek Van Ittersum
Full Member
*
Offline



Posts: 168

Re: Sending an email
Reply #14 - Jan 19th, 2010, 6:20pm
 
Hi Mark,

Thanks for the reply.  I'm a bit confused about the attribute $MyMessage in your example.  If I want to create a message out of a container and its children, do I need to feed those into an attribute somehow?  Or do I just put the container's name into that slot?

Also, I'm a bit confused about the runCommand itself.  How do I make it run?  Do I need to drop a note into another note?  What if I just want the contents of a container sent by email on a daily basis?

Sorry for the novice questions.  Thanks as always for your help!
Back to top
 
 
  IP Logged
Pages: 1 2 
Send Topic Print