EMailAddress fromAddress = this.getFromAddress(request, actionForm); if (fromAddress == null) {
EMailAddress fromAddress = new EMailAddress(); fromAddress.setAddress(sendMailForm.getFromAddress()); fromAddress.setPersonalName(sendMailForm.getFromPersonalName()); if (sendMailForm.getFromAddress() == null || !fromAddress.isValid()) {
	public ActionForward send(ActionMapping mapping, ActionForm actionForm, HttpServletRequest request,			HttpServletResponse response) throws FenixActionException, FenixFilterException,			FenixServiceException {		MessageResources resources = this.getResources(request, "CMS_RESOURCES");		IUserView userView = this.getUserView(request);		SendMailForm sendMailForm = (SendMailForm) actionForm;		IGroup[] groupsToSend = this.getGroupsToSend(actionForm, request);		if (groupsToSend == null || groupsToSend.length == 0) {			ActionMessages errors = new ActionMessages();			errors.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("cms.mailSender.selectAtLeastOneGroup"));			saveErrors(request, errors);			return this.start(mapping, actionForm, request, response);		}		SendEMailParameters parameters = new SendEMailParameters();		parameters.subject = sendMailForm.getSubject();		parameters.message = sendMailForm.getMessage();		parameters.toRecipients = groupsToSend;		parameters.allowedSenders = this.getAllowedGroups(request, groupsToSend);		EMailAddress fromAddress = this.getFromAddress(request, actionForm);		if (fromAddress == null) {			ActionMessages errors = new ActionMessages();			errors.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("cms.mailSender.provideValidFromEMailAddress"));			saveErrors(request, errors);			return this.start(mapping, actionForm, request, response);		}		parameters.from = fromAddress;		try {			SendMailReport result = (SendMailReport) ServiceManagerServiceFactory.executeService(userView, "SendEMail", new Object[] { parameters });			StringBuffer sent = new StringBuffer();			StringBuffer invalidAddress = new StringBuffer();			StringBuffer transportError = new StringBuffer();			StringBuffer invalidName = new StringBuffer();			int invalidAddressCount = 0;			int invalidPersonalNameCount = 0;			int transportErrorCount = 0;			int sentCount = 0;			if (result.get(SendStatus.INVALID_ADDRESS) != null) {				for (Person person : result.get(SendStatus.INVALID_ADDRESS)) {					if (invalidAddressCount == 0) invalidAddress.append("<ul>");					invalidAddressCount++;					String addressToShow = person.getEmail();					if (addressToShow == null || addressToShow.equals("")) {						addressToShow = resources.getMessage(this.getLocale(request), "cms.mailSender.emptyAddress");					}					invalidAddress.append("<li>").append(person.getNome()).append(" (").append(addressToShow).append(") </li>");				}			}			if (result.get(SendStatus.INVALID_PERSONAL_NAME) != null) {				for (Person person : result.get(SendStatus.INVALID_PERSONAL_NAME)) {					if (invalidPersonalNameCount == 0) invalidName.append("<ul> ");					invalidPersonalNameCount++;					invalidName.append("<li>").append(person.getNome()).append("</li>");				}			}			if (result.get(SendStatus.TRANSPORT_ERROR) != null) {				for (Person person : result.get(SendStatus.TRANSPORT_ERROR)) {					if (transportErrorCount == 0) transportError.append("<ul>");					transportErrorCount++;					transportError.append("<li>").append(person.getNome()).append(" (").append(person.getEmail()).append(") </li>");				}			}			if (result.get(SendStatus.SENT) != null) {				for (Person person : result.get(SendStatus.SENT)) {					if (sentCount == 0) sent.append("<ul>");					sentCount++;					sent.append("<li>").append(person.getNome()).append(" (").append(person.getEmail()).append(")</li>");					break;				}			}			invalidAddress.append("</ul>");			invalidName.append("</ul>");			transportError.append("</ul>");			sent.append("</ul>");			ActionMessages errors = new ActionMessages();			if (invalidAddressCount > 0) {				errors.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("cms.mailSender.invalidAddress", invalidAddressCount, invalidAddress));			}			if (invalidPersonalNameCount > 0) {				errors.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("cms.mailSender.invalidPersonalName", invalidPersonalNameCount, invalidName));			}			if (transportErrorCount > 0) {				errors.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("cms.mailSender.transportError", transportErrorCount, transportError));			}			saveErrors(request, errors);			ActionMessages messages = new StartHiddenActionMessages();			if (sentCount > 0) {				messages.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("cms.mailSender.sent", sentCount, sent));			}			saveMessages(request, messages);		}		catch (Exception e) {			throw new FenixActionException(e);		}		return mapping.findForward("sendMail");	}