do shell script OS X inbuild smtp server

Hi All

OS X has its own inbuild smtp server, not a secret.

I have a script with only one step (perform applescript) which contains this:

do shell script “echo Body | mail -s ‘Subject’ hanson@it.dk”

How do i include: From name, From address, cc, ccc, attachments in this do shell script ?

And can smpt port, account name/password etc. be specified in the same line ?

Regards

jan Hanson

Hello hanson,

almost a ‘RTFM’ question - ‘man mail’ helps :wink: You can include CC and BCC addresses using the -c and -b flags in the mail command:

“echo Body | mail -s ‘Subject’ -c cc_address@dummy.de -b bcc_address@dummy.de usual_recipient@dummy.de

Attachments is a different topic, you cannot attach files simply by specifying some additonal command line switch. Moreover, you’ll have to encode attachments before mailing them. So, if you want to do that I’d suggest to you to check whether there’s some other command line mailing tool you can use for your purpose. Maybe there’s also some OSAX or Tool out there that allows sending mail from AppleScript under OS X, but unfortunately I don’t know such a tool.

Best regards,
danB

You can also script the Mail application. Check out the scripts that iCal uses for ideas. The one problem I had was getting stylized text into the body of the message. Never worked. Resorted to copy paste using System Events.