Creates a {@link Client} object.
@param email
Mail address for the {@link Client} or <code>null</code>
@param description
Description for the client or <code>null</code>
@return {@link Client} object, which represents a PAYMILL client.
340820
public Client createWithEmailAndDescription( String email, String description ) {
    ParameterMap<String, String> params = new ParameterMap<String, String>();
    if( StringUtils.isNotBlank( email ) )
      params.add( "email", email );
    if( StringUtils.isNotBlank( description ) )
      params.add( "description", description );

    return RestfulUtils.create( ClientService.PATH, params, Client.class, super.httpClient );
  }
763358
public WebClient createWebClient() {
        String serviceAddress = getAddress();
        int queryIndex = serviceAddress != null ? serviceAddress.lastIndexOf('?') : -1;
        if (queryIndex != -1) {
            serviceAddress = serviceAddress.substring(0, queryIndex);
        }
        Service service = new JAXRSServiceImpl(serviceAddress, getServiceName());
        getServiceFactory().setService(service);

        try {
            Endpoint ep = createEndpoint();
            this.getServiceFactory().sendEvent(FactoryBeanListener.Event.PRE_CLIENT_CREATE, ep);
            ClientState actualState = getActualState();
            WebClient client = actualState == null ? new WebClient(getAddress())
                : new WebClient(actualState);
            initClient(client, ep, actualState == null);

            notifyLifecycleManager(client);
            this.getServiceFactory().sendEvent(FactoryBeanListener.Event.CLIENT_CREATED, client, ep);

            return client;
        } catch (Exception ex) {
            LOG.severe(ex.getClass().getName() + " : " + ex.getLocalizedMessage());
            throw new RuntimeException(ex);
        }
    }
770357
@NonNull
    public EmailIntentBuilder cc(@NonNull Collection<String> cc) {
        checkNotNull(cc);
        for (String email : cc) {
            checkEmail(email);
        }
        this.cc.addAll(cc);

        return this;
    }
716441
protected void sendEmail(TaskRuntimeContext context, String outcome)
    throws ObserverException {
        TaskInstance taskInstance = context.getTaskInstance();
        TemplatedEmail templatedEmail = new TemplatedEmail();
        templatedEmail.setFromAddress(getFromAddress());
        templatedEmail.setSubject(getSubject(taskInstance, outcome));
        templatedEmail.setHtml(true);
        templatedEmail.setTemplateAssetVerSpec(getTemplateSpec());
        templatedEmail.setRuntimeContext(context);

        try {
            List<Address> recipients = getRecipientAddresses(outcome);
            List<Address> ccRecipients = getCcRecipientAddresses(outcome);

            if (templatedEmail.getTemplateBody().contains("${taskActionUrl}")) {

                // send individual e-mails
                for (Address recip : recipients) {
                    String cuid = recip.toString().substring(0, recip.toString().indexOf('@'));
                    String userIdentifier = MiniCrypter.encrypt(cuid);
                    taskInstance.setUserIdentifier(userIdentifier);
                    templatedEmail.setRecipients(new Address[]{recip});
                    templatedEmail.setCcRecipients(new Address[0]);
                    try {
                        templatedEmail.sendEmail();
                    }
                    catch (MessagingException ex) {
                        logger.severeException(ex.getMessage(), ex);  // do not rethrow
                    }
                }
                if (ccRecipients != null) {
                    for (Address ccRecip : ccRecipients) {
                        String cuid = ccRecip.toString().substring(0, ccRecip.toString().indexOf('@'));
                        String userIdentifier = MiniCrypter.encrypt(cuid);
                        taskInstance.setUserIdentifier(userIdentifier);
                        templatedEmail.setRecipients(new Address[0]);
                        templatedEmail.setCcRecipients(new Address[]{ccRecip});
                        try {
                            templatedEmail.sendEmail();
                        }
                        catch (MessagingException ex) {
                            logger.severeException(ex.getMessage(), ex);  // do not rethrow
                        }
                    }
                }
            }
            else {
                if ((recipients != null && !recipients.isEmpty()) || (ccRecipients != null && !ccRecipients.isEmpty())) {
                    if (recipients != null)
                        templatedEmail.setRecipients(recipients.toArray(new Address[0]));
                    if (ccRecipients != null)
                        templatedEmail.setCcRecipients(ccRecipients.toArray(new Address[0]));
                    try {
                        templatedEmail.sendEmail();
                    }
                    catch (MessagingException ex) {
                        logger.severeException(ex.getMessage(), ex);  // do not rethrow
                    }
                }
                else {
                    logger.warn("WARNING: No email recipients for task " + context.getTaskInstanceId() + " " + outcome);
                }
            }
        }
        catch (Exception ex) {
            logger.severeException(ex.getMessage(), ex);
            throw new ObserverException(-1, ex.getMessage(), ex);
        }
    }
112944
public static EmailTextField newEmailTextField(final String id, final IModel<String> model)
	{
		final EmailTextField emailTextField = new EmailTextField(id, model);
		emailTextField.setOutputMarkupId(true);
		return emailTextField;
	}
136661
public MimeMessage createMimeMessage(Session session) throws MessagingException {
		if (isEmpty(htmlPart) && isEmpty(textPart)) {
			throw new IllegalArgumentException("Missing email content");
		}
		final MimeMessage msg = new MimeMessage(session);
		msg.setSubject(subject);
		msg.setFrom(new InternetAddress(from));
		msg.setContent(createMultiPart());
		msg.setRecipients(Message.RecipientType.TO, InternetAddress.parse(recipients, false));
		return msg;
	}
425695
public static Result failure(String message, String description) {
        return new Result(message, description, null);
    }
517029
public OvhOrder email_domain_new_duration_POST(String duration, String domain, OvhOfferEnum offer) throws IOException {
		String qPath = "/order/email/domain/new/{duration}";
		StringBuilder sb = path(qPath, duration);
		HashMap<String, Object>o = new HashMap<String, Object>();
		addBody(o, "domain", domain);
		addBody(o, "offer", offer);
		String resp = exec(qPath, "POST", sb.toString(), o);
		return convertTo(resp, OvhOrder.class);
	}
652398
public MimeMessage getMessage(Session session) {

		Assert.notNull(emails, "No email address given!");

		Map<String, String> recipients = emails.get(Message.RecipientType.TO);
		Assert.isTrue(recipients != null && recipients.size() > 0, "Missing to email address(es)!");

		boolean found = false;
		for (String email : recipients.keySet()) {
			if (!excluded(email)) { // at least one address is not excluded
				found = true;
				break;
			}
		}

		Assert.isTrue(found, "All to email address(es) are excluded!");

		if (StringUtils.isNullOrEmptyTrimmed(fromName)) {
			fromName = fromEmail;
		}

		Assert.notNullOrEmptyTrimmed(fromEmail, "Missing from email address!");
		Assert.notNullOrEmptyTrimmed(subject, "Missing email subject!");

		Assert.isTrue(!StringUtils.isNullOrEmptyTrimmed(content) || !StringUtils.isNullOrEmptyTrimmed(htmlContent), "Missing email content!");

		subject = subject.trim();
		content = content != null ? content.trim() : null;
		htmlContent = htmlContent != null ? htmlContent.trim() : null;

		log.info("Sending from: " + fromEmail + " (" + fromName + ")");

		MimeMessage msg = new MimeMessage(session);

		// FROM:
		try {
			msg.setFrom(new InternetAddress(fromEmail, fromName, UTF_8));

			// TO:
			addRecipients(Message.RecipientType.TO, msg);
			// CC:
			addRecipients(Message.RecipientType.CC, msg);
			// BCC:
			addRecipients(Message.RecipientType.BCC, msg);

			//msg.setSubject(subject, UTF_8);
			msg.setSubject(MimeUtility.encodeText(subject, UTF_8, "Q"));

			// add headers
			if (headers != null && headers.size() > 0) {
				for (String name : headers.keySet()) {
					msg.addHeader(name, headers.get(name));
				}
			}

			try {
				// simple message .. no attachment and only content or html content
				if ((attachments == null || attachments.size() == 0) &&
				    ((htmlContent == null && content != null) ||
				     (htmlContent != null && content == null))) {

					if (StringUtils.isNullOrEmptyTrimmed(content)) {
						msg.addHeader("Content-Type", "text/html");
						msg.setContent(htmlContent, "text/html; charset=" + UTF_8);
					} else {
						msg.setContent(content, "text/plain; charset=" + UTF_8);
					}
				}
				// Compose multipart message
				else {
					// must be in correct order from lower fidelity to higher
					Multipart multipart = new MimeMultipart();

					if (!StringUtils.isNullOrEmptyTrimmed(content)) {
						MimeBodyPart contentPart = new MimeBodyPart();
						contentPart.setContent(content, "text/plain; charset=" + UTF_8);
						multipart.addBodyPart(contentPart);
					}

					if (!StringUtils.isNullOrEmptyTrimmed(htmlContent)) {
						MimeBodyPart htmlPart = new MimeBodyPart();
						htmlPart.setContent(htmlContent, "text/html; charset=" + UTF_8);
						multipart.addBodyPart(htmlPart);
					}

					if (attachments != null && attachments.size() > 0) {
						for (MailAttachment attachment : attachments) {

							// add attachment
							MimeBodyPart part = new MimeBodyPart();
							if (attachment.fileName != null) {
								part.setFileName(attachment.fileName);
							}
							DataSource src = new ByteArrayDataSource(attachment.content, attachment.type);
							part.setDataHandler(new DataHandler(src));
							multipart.addBodyPart(part);
						}
					}

					msg.setContent(multipart);
				}

				// if save is not called mime part headers are not updated
				msg.saveChanges();
				// see: http://stackoverflow.com/questions/5028670/how-to-set-mimebodypart-contenttype-to-text-html
			}
			catch (Exception e) {
				log.error("Failed to add attachment to mail message: ", e);
				throw new IllegalArgumentException(e.getMessage(), e);
			}

		}
		catch (MessagingException | UnsupportedEncodingException e) {
			log.error("Mail massage build failed!", e);
			throw new IllegalArgumentException(e.getMessage(), e);
		}

		return msg;
	}
64028
protected void generateIMemberBuilder(MemberDescription description) {
		if (description.isTopElement()) {
			return;
		}
		final TypeReference builder = description.getElementDescription().getBuilderInterfaceType();
		final StringConcatenationClient content = new StringConcatenationClient() {
			@Override
			protected void appendTo(TargetStringConcatenation it) {
				it.append("/** Builder of a " + getLanguageName() //$NON-NLS-1$
						+ " " + description.getElementDescription().getName() + "."); //$NON-NLS-1$ //$NON-NLS-2$
				it.newLine();
				it.append(" */"); //$NON-NLS-1$
				it.newLine();
				it.append("@SuppressWarnings(\"all\")"); //$NON-NLS-1$
				it.newLine();
				it.append("public interface "); //$NON-NLS-1$
				it.append(builder.getSimpleName());
				it.append(" {"); //$NON-NLS-1$
				it.newLineIfNotEmpty();
				it.newLine();
				it.append(generateMembers(description, true, false));
				it.append("}"); //$NON-NLS-1$
				it.newLineIfNotEmpty();
				it.newLine();
			}
		};
		final JavaFileAccess javaFile = getFileAccessFactory().createJavaFile(builder, content);
		javaFile.writeTo(getSrcGen());
	}
670987
public Email cc(EmailAddress... cc) {
		for (EmailAddress c : cc) {
			recipient(c, RecipientType.CC);
		}
		return this;
	}
1153211
public OvhXdslEmailPro email_pro_email_GET(String email) throws IOException {
		String qPath = "/xdsl/email/pro/{email}";
		StringBuilder sb = path(qPath, email);
		String resp = exec(qPath, "GET", sb.toString(), null);
		return convertTo(resp, OvhXdslEmailPro.class);
	}
946666
public MailBuilder from(String name, String email) {
        return param("from", email(name, email));
    }
1080126
public Request<EmailTemplate> create(EmailTemplate template) {
        Asserts.assertNotNull(template, "template");

        String url = baseUrl
                .newBuilder()
                .addPathSegments("api/v2/email-templates")
                .build()
                .toString();
        CustomRequest<EmailTemplate> request = new CustomRequest<>(this.client, url, "POST", new TypeReference<EmailTemplate>() {
        });
        request.addHeader("Authorization", "Bearer " + apiToken);
        request.setBody(template);
        return request;
    }
1175317
@Override
	public String getEmail() {
		StringBuilder sb = new StringBuilder();

		sb.append(getFirstName().toLowerCase());
		sb.append(".");
		sb.append(getLastName().toLowerCase());
		sb.append("@example.com");

		return sb.toString().replace(' ', '.');
	}
512188
private String createMailToLink(String to, String bcc, String cc,
            String subject, String body) {
        Validate.notNull(to, "You must define a to-address");
        final StringBuilder urlBuilder = new StringBuilder("mailto:");
        addEncodedValue(urlBuilder, "to", to);
        if (bcc != null || cc != null || subject != null || body != null) {
            urlBuilder.append('?');
        }
        addEncodedValue(urlBuilder, "bcc", bcc);
        addEncodedValue(urlBuilder, "cc", cc);
        addEncodedValue(urlBuilder, "subject", subject);
        if (body != null) {
            addEncodedValue(urlBuilder, "body", body.replace("$NL$", "\r\n"));
        }

        return urlBuilder.toString();
    }
678555
public static ObjectName createJavaMailObjectName(String serverName, String mailSessionID, int resourceCounter) {
        Hashtable<String, String> props = new Hashtable<String, String>();
        props.put(TYPE_SERVER, serverName);
        props.put(MAIL_SESSION_ID, mailSessionID);
        props.put(RESOURCE_ID, TYPE_JAVA_MAIL_RESOURCE + "-" + resourceCounter);
        ObjectName objectName;
        try {
            objectName = createObjectName(TYPE_JAVA_MAIL_RESOURCE, NAME_JAVA_MAIL_RESOURCE, props);
        } catch (IllegalArgumentException e) {
            // mailSessionID contains illegal characters
            props.remove(MAIL_SESSION_ID);
            objectName = createObjectName(TYPE_JAVA_MAIL_RESOURCE, NAME_JAVA_MAIL_RESOURCE, props);
        }
        return objectName;
    }