Sending mail through the shell via the sendmail command

Okay I’m trying to use AppleSript to send mail through the shell via the sendmail command. I’m running 10.3, fully up-to-date.

Is it possible to specify all of the parameters including from, recipient, subject and message body all on one line? Or is sendmail not the right app for this?

I already have Postfix working for SMTP, and I don’t want to use Apple’s Mail program to build the message. Nor do I wish to implement some AppleScript osax (scripting addition) unless I absolutely have to.

I’ve been looking though the discussions and just have not found any example of the actual full command. And yes, I’ve read the man page for sendmail, but I’m still not clear on how to formulate it. Any help would be appreciated.

Same answer to your post on the Apple boards :slight_smile:

The following code works for me:

do shell script "sendmail -bm someone@somewhere.com < /path/to/file.txt"

This will send the contents of the file ‘/path/to/file.txt’ to someone@somewhere.com
There’s no way to pass the message in on the command line, so you have to use an intermediate file.

The trick with ‘from’ and ‘subject’ is that you have to embed them in the file - there’s no way to specify them on the command line.

Consequently the file should look something like:

Subject: Here is your subject
From: My Name me@mydomain.com

Here’s the message body. The above blank line is essential - it separates the mail headers from the body.

Is there anyway to use this script, but copy the contents of a log file into the .txt before mailing it ?