Hi ,
I tried to send mail to the members of the group from the administrator . Am getting this error in python script
AttributeError: email_from_address
The script is as follows:
##parameters=state_change
# the objects we need229
object = state_change.object
mship = context.portal_membership
mhost = context.MailHost
administratorEmailAddress = context.email_from_address
# the message format, %s will be filled in from data
message = """
From: %s
To: %s
Subject: New item submitted for approval - %s
%s
URL: %s
"""
for user in mship.listMembers():
if "Reviewer" in mship.getMemberById(user.id).getRoles():
if user.email:
msg = message % (
administratorEmailAddress,
user.email,
object.TitleOrId(),
object.Description(),
object.absolute_url()
)
mhost.send(msg)
Obviously your current context object has no attribute email_from_address.
So what is exactly context in your case? And why would this attribute be missing or where would it come from?
The code might be valid for Plone 4.x but it is no longer valid for Plone 5 since most configurations are nowadays stored within the configuration registry.
I am pretty sure something happened between Plone 5 'beta' and the current Plone version.
Maybe the 'mail-definition in the registry has moved' ( to plone.email_from_address).
I have a browser view that does something similar to what you try to do (I think):
PS: Pay no attention to the 'attach images part… I never got that to work)