Hello all. I’m new with scripting, but I need to do a script urgently.
I need to make a script (filter) for the QuickMail Server that will check if the outgoing mail is going to a certain domain. If it is, then I want to continue normal processing; else I want to add a certain address to be safe-kept in. This is what I came up with.
on «event QMPSMAIL» {sender, recipient, subject, body, mailfile, options, trigger}
tell application "QuickMail Server"
if recipient contains "@contadress1.com" or "@contadress2.com" then
send mail current from sender to |recipient|
else
recipent = recipient + "admin@contadress1.com"
send mail current from sender to |recipient|
end if
end tell
end «event QMPSMAIL»
Can you please check the functionality of the script and if possible to modify it. Any help will be much appreciated.
Small thing, but it could be giving you problems - you’ve mistyped ‘recipient’ as ‘recipent’ in the above script, so ‘recipient’ never actually changes!
on «event QMPSMAIL» {sender, recipient, subject, body, mailfile, options, trigger}
tell application "QuickMail Server"
if recipient ends with "@contadress1.com" or recipient ends with "@contadress2.com" then
send mail current from sender to |recipient|
else
set recipient to recipient & "admin@contadress1.com"
send mail current from sender to |recipient|
end if
end tell
end «event QMPSMAIL»
and it is still not working… and i’m sure it because of the
send mail current from sender to |recipient|
because i tryied this script
on «event QMPSMAIL» {sender, recipient, subject, body, mailfile, options, trigger}
tell application "Finder"
if recipient ends with "@contadress1.com" or recipient ends with "@contadress2.com" then
display dialog "internal msg"
else
display dialog "external msg"
end if
end tell
end «event QMPSMAIL»
and it is working fine…
so i need advice desperatly on the
Hi, psycho-ed. Sorry for the delayed response. (Obviously not too many folks around here scripting QuickMail Server.)
If the variable mailfile refers to the file of the message that you want to send, then try that in place of current. (I can’t be sure - but current doesn’t look right.)
Also, there may be a potential conflict with the variable labels you’re using (and even if there’s not, it shouldn’t do any harm to play it safe here). For example, instead of using recipient, which may be interpreted as an application keyword, try something like theRecipient or myRecipient. Make sure you use the same variable name at the beginning of the handler, too. So the handler’s first line might look like this:
… and the send statement like this:
Only guessing, of course - but I hope that gets you a bit closer. (If you have further problems, perhaps you could give details of the error message you get.)
the theMailfile worked… but i have another problem now… it seems that quickmail server doesnt support multipple recipient… what can i do?/ the server is saying multiple recipient can’t sent… and returns the mail…
to all those who are interested…
and to all those who helped…
this is the working script
on «event QMPSMAIL» {sender, recipient, subject, body, mailfile, options, trigger}
tell application "QuickMail Server"
if recipient ends with "@contadress1.com" or recipient ends with "@contadress1.com" then
beep
else
set body to "Sent to: " & recipient & return & return & body
send note subject from sender to "admin@contadress1.com" message body
end if
end tell
end «event QMPSMAIL»
Thanks for the feedback, psycho-ed. It’s always good to hear whether or not suggestions have helped.
Sorry, I must have missed your question about multiple recipients (although I’m not sure I could have been much help on that). Anyway, delighted to hear that you got it all working in the end. Well done!
I guess this must mean that you’re now our top QuickMail Server expert!