QuickMail Server: Change recipient of outgoing mail

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.

Regard,
Psycho

Hi psycho,

the above line should be:

set recipent to recipient & "admin@contadress1.com"

sorry I don’t have ‘QuickMail’ - so I can’t say sth about the rest of your script

D.

Small thing, but it could be giving you problems - you’ve mistyped ‘recipient’ as ‘recipent’ in the above script, so ‘recipient’ never actually changes!

Emma

Thanks a lot Emma and Dominik,

Dominik I changed it to what you said and fixed emmas comment. and yet it didn’t work. :S

I think that this part isn’t working.

 send mail current from sender to |recipient|

specifically the current comment. Can anyone help?? Also, is this syntax correct?

 if recipient contains "@contadress1.com" or "@contadress2.com" then

Thanks a lot,
Psycho-ed

I’m no QuickMail Server guy either, psycho-ed - but I think you’ve hit on a couple of likely problems…

I’d try something like:

send mail current from sender to recipient

No, that should be:

if recipient contains "@contadress1.com" or recipient contains "@contadress2.com" then

Better still, you could even do this:

if recipient ends with "@contadress1.com" or recipient ends with "@contadress2.com"

I doubt that I can be of much help with the rest of the code, but I hope that helps a little.

Good luck! :slight_smile:

thanks kai,

this is my script now


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

send mail current from sender to |recipient|

command can i use current like that?

thanks in advance,
psycho-ed

i need help quickly, this is an urgent matter…
thanks,
psycho-ed

Hi, psycho-ed. Sorry for the delayed response. (Obviously not too many folks around here scripting QuickMail Server.) :confused:

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.)

thatnks a lot kai :)…

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…

thanks again for the help…

Regards,
psycho-ed

to all those who are interested…
and to all those who helped…
this is the working script :smiley:


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»

Regards,
Psycho-ed

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! :smiley:

lool :cool:
but not really… now all of u guys know all what i know about quickmail hehe
thanks for ur replies kai.

laterz,
psycho-ed