Running applescript on different users account.

It worked actually although I didn’t see anything in applescripts log it still send now there is just 1 problem.

The message came through as text and “Subject: MIME Test Mime-Version: 1.0 Content-Type: text/html” appeared in the message body along with all the html code.

Any reason as to why this is happening?

With what mail client did you open the mail? If it’s an text mail it will be presented as text and not as HTML, many webmail clients do this for example. If you’re using a mail client that should support html but still represent their message wrong, maybe you need this in the SMTP headers as well:

Content-Transfer-Encoding: 7bit

edit: NOTE: Apple Mail is making up two mail bodies in one single mail, a HTML version and a plain text version. You can do this too if you want.

I opened it up in iOS mail which I used when i was copy and pasting it into an email and it worked fine I will try with the encoding and see what happens.

Thanks,
Bruce

Mmmm, that’s weird. I opened mine (copy of the latest AppleScript here) and the mail doesn’t show any HTML tags at all, I only see “this is a test” without the tags.

p.s. tested with iOS 7.1.2

I used iOS 7.1.2 as well and it could be to do with my HTML I was using the webpage I want to send in the test because I need to know if it works with it. unfortunately it does not look like it works.

Hmm wonder what else I could try…

EDIT: I did try the encoding and not sure where to put it exactly

I know it does work :cool:

Just somewhere between the other headers.

You can test it also otherwise:

  • make a mail in Mail.app and fill in everything including subject en to whom you want to send the mail to.
  • save the mail somewhere on your machine (let’s say /mymail.eml), be sure you don’t save it as rtf but as source mail
  • then run the following script:
do shell script "sendmail -t </mymail.eml"

I have tried putting at the bottom and between the subject and body and before the subject.

If I try it outside of the quotation marks at the top I get Syntax Error: A “:” can’t go after this identifier.

Everywhere else I have tried it send the mail yet it still sends as text instead of the page I got the code off.

Thanks,
Bruce

I just tried sending a message file using:

tell application "System Events" to set parentFolder to POSIX path of container of (path to me)
set filename to "Test.eml"
set mail to (parentFolder & "/" & filename)

do shell script "sendmail -t mail"

Unfortunately the result is “” and no email has been sent!

any reason as to why this is?

Thanks,
Bruce

you have to pass the variable mail, not the literal string “mail”.
And add always quoted form of to handle space characters in the path properly


do shell script "sendmail -t " & quoted form of mail

Just tried it got this error:
Applescript error:
sendmail: illegal option – /
sendmail: illegal option – s
sendmail: illegal option – /
sendmail: fatal: usage: sendmail [options]

EDIT:

Never mind didn’t include a space between -t "

I don’t know the syntax of sendmail, but in post #26 there is an < character in front of the path


do shell script "sendmail -t <" & quoted form of mail

Sorry for late response, it’s our loss against Argentina from last night.

What you need to to i slike Stefan said bit the file contents needs to be send to sendmail, not the file name.

tell application "System Events" to set parentFolder to POSIX path of container of (path to me)
set filename to "Test.eml"
set mail to (parentFolder & "/" & filename)

do shell script "sendmail -t <" & quoted form of mail

edit: Like Stefan said. He was posting while was writing, sorry for double post.

Thanks guys for your responses but it still is showing “” and not sending anything.

I done it with and without < and it hasn’t made a difference.

tell application "System Events" to set parentFolder to POSIX path of container of (path to me)
set filename to "Test.eml"
set message to parentFolder & "/" & filename

do shell script "sendmail -t <" & quoted form of message

Just look in the console and see what it says there.

Hi,

Sorry for the late reply had a long weekend.

Before I left I did this and I noticed it worked but it ended up in both inboxes


tell application "System Events" to set parentFolder to POSIX path of container of (path to me)
set filename to "Test.eml"
set message to parentFolder & "/" & filename

do shell script "sendmail -t email@email.co.uk to address@address.com <" & quoted form of message

when the first email address is not there it send but it receives saying no sender.

any idea why this could be?

to is not a valid command line argument for sendmail.

Hi, tried it with out the to and now Im not getting anything at all.

Any reason as to why?

Thanks,
Bruce

Have you looked into your console? If there is anything wrong with the markup of the Mail or communication with the SMTP server you have to look there.

here is the log for it, if its right?

Thanks,
Bruce

That is right. The 250 OK message indicates that everything has worked properly. A common issue now is that the mail could not be delivered to the proper mail box, something that is handled by the remote server (smtp.emailsrvr.com) and not by sendmail. You have defined a sender but make sure that <server@osx server domain.private> also accepts bounce backs from other mail servers (an informative mail that indicates what went wrong on the remote server). Another common issue is a spam filter who catches the mail and doesn’t deliver the mail properly in the inbox.