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!
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
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.
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.
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.
The server@osx serverdomain.private is the name of the computer (well changed) because a while ago I was trying to set up a VPN not knowing the ISP blocked most ports and won’t allow you to open them and when I had apple tech support to help me they changed the name of the computer to a no-ip domain which was being used to redirect to the IP as it was not static at the time so thats become the computers name.
Anyway thats the address that showed up when I didn’t configure the file properly but now that I have and have defined my email address and SMTP server it should not be showing that although it seems to be trying to send emails through OSX’s email utility which won’t work as I do not have it enabled but it should not be trying to do that anyway any reason as to why that is?
EDIT:
Didn’t want to bump and did not realise that the SMTP server in the sasl_passwd file needed a port will give it another try in a second
EDIT 2:
Still not sending and just looked at the log file, it is still trying to send from OSX server mail and not from the defined email address rather strange considering it was working at one point and no changed have been made.
So I have managed to be able to get it to work using -f and -t.
Now I want to be able to use a bit of code I got from a previous forum post which repeats the script changing the recipient every time and ending the script when it reaches the end of the file.
This is what I have at the moment:
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
display dialog "Choose Mail Group" buttons {"test", "Test Bulk", "bulktest"}
if result = {button returned:"test"} then
set theGroups to "test"
set theFileName to "test.csv"
set theEmailGroup to paragraphs of (do shell script ("egrep -o '\\b[a-zA-Z0-9.-]+@[a-zA-Z0-9.-]+\\.[a-zA-Z0-9.-]+' " & quoted form of (parentFolder & "/" & theFileName)))
end if
set EmailAddresses to theEmailGroup
repeat with i from 1 to count of EmailAddresses
do shell script "sendmail -f my@email.co.uk -t & EmailAddresses <" & quoted form of message
end repeat
I can’t seem to get the variable EmailAddresses to work as it is within the quotation marks and when I move it out of them the script expects end of line.