Creates the mailto-link.

@param to the to-address
@param bcc optional a bcc
@param cc optional a cc
@param subject optional a subject
@param body optional a body
@return the link.
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();
    }
229414
protected boolean sendPasswordResetEmailToAccount(final String to, final String url) {
        val reset = casProperties.getAuthn().getPm().getReset().getMail();
        val text = reset.getFormattedBody(url);
        return this.communicationsManager.email(reset, to, text);
    }
1366163
@Override
	public WebMvcLinkBuilder linkTo(Class<?> controller, Map<String, ?> parameters) {
		return WebMvcLinkBuilder.linkTo(controller, parameters);
	}
1308561
public static function getHtmlMail($mailView, $params, $to, $from, $subject) {
        if (file_exists($mailView)) {
            ob_start();
            require_once $mailView;
            $body = ob_get_contents();
            ob_end_clean();
        } else {
            throw new MailViewException($mailView);
        }

        $mail = new MailMessage($to, $from, $body, $subject);
        $headers = "MIME-Version: 1.0\r\n"
                . "Content-Type: text/html; charset=utf-8\r\n"
                . "Content-Transfer-Encoding: 8bit\r\n"
                . "From: =?UTF-8?B?" . base64_encode($params["from_name"]) . "?= <" . $from . ">\r\n"
                . "X-Mailer: PHP/" . phpversion();
        $mail->setHeaders($headers);
        return $mail;
    }
473476
public function setTextMessage(array $to,
                                   string $subject,
                                   string $body,
                                   array $attachment = null,
                                   array $cc = null,
                                   array $bcc = EMAIL_BCC): void
    {
        $this->email->setFrom($this->from);
        foreach ($to as $value) {
            $this->email->addTo($value);
        }
        if ($cc != null) {
            foreach ($cc as $value) {
                $this->email->addCc($value);
            }
        }
        if ($bcc != null) {
            foreach ($bcc as $value) {
                $this->email->addBcc($value);
            }
        }
        if ($attachment != null) {
            foreach ($attachment as $file) {
                $this->email->addAttachment($file);
            }
        }
        $this->email->setSubject($subject);
        $this->email->setBody($body);
    }
555520
private function _mail($to, $subject, $message)
		{
			// Set up swift mailer if needed
			if (!$this->_mailer) {
				$transport = NULL;
				// Set transport to php
				if (strtolower($this->transportType) == 'php') {
					$transport = Swift_MailTransport::newInstance();
				} // Set transport to smtp
				elseif (strtolower($this->transportType) == 'smtp') {
					$transport = \Swift_SmtpTransport::newInstance();

					foreach ($this->transportOptions as $option => $value) {
						$methodName = 'set' . ucfirst($option);
						$transport->$methodName($value);
					}
				}

				// Create Mailer object
				$this->_mailer = \Swift_Mailer::newInstance($transport);
			}

			// Set up message
			$mailer  = $this->_mailer;
			$message = Swift_Message::newInstance($subject)->setFrom('not@used.com')->setTo($to)->setBody($message);

			return $mailer->send($message);
		}
433292
public AwsSesSendResult sendEmail(
      @Nonnull final String to,
      @Nonnull final String from,
      @Nonnull final String subject,
      @Nonnull final String body) {
    return proxy.sendEmail(to, from, subject, body);
  }
259648
def send_mail(subject, text_content, from_email, to, html_content=None, attachments=[], cc=[], bcc=[]):
    
    msg = EmailMultiAlternatives(subject, text_content, from_email, to, cc=cc, bcc=bcc)
    if html_content:
        msg.attach_alternative(html_content, "text/html")
    if attachments:
        for att in attachments:
            if att:

                mimetype = mimetypes.guess_type(att)[0]
                if str(mimetype) in ('image/jpeg', 'image/pjpeg', 'image/png', 'image/gif'):
                    try:
                        with open(att, 'r') as f:
                            email_embed_image(msg, att, f.read())
                    except Exception as e:
                        print(e)
                else:
                    msg.attach_file(att)
    return msg.send()
414192
public void sendMail (String to, String subject, String content) throws MessagingException {
        Properties props = new Properties();
        props.put("mail.smtp.user", emailConfg.getUser());
        props.put("mail.smtp.host", emailConfg.getHost());
        props.put("mail.smtp.port", emailConfg.getPort());
        props.put("mail.smtp.starttls.enable","true");
        props.put("mail.smtp.debug", emailConfg.getDebug());
        props.put("mail.smtp.auth", emailConfg.getAuth());
        props.put("mail.smtp.ssl.trust", emailConfg.host);

        SMTPAuthenticator auth = new SMTPAuthenticator(emailConfg.getUser(), (String)secret.get(SecretConstants.EMAIL_PASSWORD));
        Session session = Session.getInstance(props, auth);

        MimeMessage message = new MimeMessage(session);

        message.setFrom(new InternetAddress(emailConfg.getUser()));
        message.addRecipient(Message.RecipientType.TO, new InternetAddress(to));

        message.setSubject(subject);

        message.setContent(content, "text/html");

        // Send message
        Transport.send(message);
        if(logger.isInfoEnabled()) logger.info("An email has been sent to " + to + " with subject " + subject);
    }
1177026
def EmailTemplate(
        self,
        TemplateId,
        TemplateModel,
        From,
        To,
        TemplateAlias=None,
        Cc=None,
        Bcc=None,
        Subject=None,
        Tag=None,
        ReplyTo=None,
        Headers=None,
        TrackOpens=None,
        TrackLinks="None",
        Attachments=None,
        InlineCss=True,
    ):
        
        return EmailTemplate(
            manager=self,
            TemplateId=TemplateId,
            TemplateAlias=TemplateAlias,
            TemplateModel=TemplateModel,
            From=From,
            To=To,
            Cc=Cc,
            Bcc=Bcc,
            Subject=Subject,
            Tag=Tag,
            ReplyTo=ReplyTo,
            Headers=Headers,
            TrackOpens=TrackOpens,
            TrackLinks=TrackLinks,
            Attachments=Attachments,
            InlineCss=InlineCss,
        )
168808
def Email(
        self,
        From,
        To,
        Cc=None,
        Bcc=None,
        Subject=None,
        Tag=None,
        HtmlBody=None,
        TextBody=None,
        Metadata=None,
        ReplyTo=None,
        Headers=None,
        TrackOpens=None,
        TrackLinks="None",
        Attachments=None,
    ):
        
        return Email(
            manager=self,
            From=From,
            To=To,
            Cc=Cc,
            Bcc=Bcc,
            Subject=Subject,
            Tag=Tag,
            HtmlBody=HtmlBody,
            TextBody=TextBody,
            Metadata=Metadata,
            ReplyTo=ReplyTo,
            Headers=Headers,
            TrackOpens=TrackOpens,
            TrackLinks=TrackLinks,
            Attachments=Attachments,
        )
567881
public void fillEmail(final MultiPartEmail email) throws EmailException, IOException {
		email.setHostName(getHost());
		email.setSmtpPort(getSmtpPort());

		email.addTo(getTo());
		email.setFrom(getFrom());
		email.setSubject(getSubject());
		email.setMsg(getMsg());
		email.setSSLOnConnect(isSecured());
		if(this.bcc!=null) {
			String[] bccList = this.bcc.split(",");
			for (String bcc : bccList) {
				email.addBcc(bcc);
			}
		}
		if(this.cc!=null) {
			String[] ccList = this.cc.split(",");
			for (String cc : ccList) {
				email.addCc(cc);
			}
		}
		
		if (isRequiresAuthentication()) {
			email.setAuthentication(getUsername(), getPassword());
		}
		for (int i = 0; i < this.attachements.size(); i++) {
			final Attachment attachment = this.attachements.get(i);
			final ByteArrayDataSource ds = new ByteArrayDataSource(attachment.getData(), attachment.getMimeType());
			email.attach(ds, attachment.getName(), attachment.getDescription());
		}
	}
1011298
public static function sendHtmlEmail (\stdClass $emailBody, \stdClass $to, \stdClass $from, \stdClass $replyTo, $SMTPConfig='') : bool
	{
		$mail = new PHPMailer;
		static::setSMTPConfig($mail, $SMTPConfig);
	    $mail->Subject 	= $emailBody->subject;
	    $mail->MsgHTML($emailBody->messageBody);
	    $mail->addAddress($to->email, $to->name);
	    $mail->setFrom($from->email, $from->name);
		$mail->addReplyTo($replyTo->email, $replyTo->name);
		static::$result 		= $mail->send();
		static::$errorMessage 	= $mail->ErrorInfo;
	    return static::$result ? TRUE : FALSE;
	}
1081320
public void sendMailWithAttachment (String to, String subject, String content, String filename) throws MessagingException{
        Properties props = new Properties();
        props.put("mail.smtp.user", emailConfg.getUser());
        props.put("mail.smtp.host", emailConfg.getHost());
        props.put("mail.smtp.port", emailConfg.getPort());
        props.put("mail.smtp.starttls.enable","true");
        props.put("mail.smtp.debug", emailConfg.getDebug());
        props.put("mail.smtp.auth", emailConfg.getAuth());
        props.put("mail.smtp.ssl.trust", emailConfg.host);

        SMTPAuthenticator auth = new SMTPAuthenticator(emailConfg.getUser(), (String)secret.get(SecretConstants.EMAIL_PASSWORD));
        Session session = Session.getInstance(props, auth);

        MimeMessage message = new MimeMessage(session);

        message.setFrom(new InternetAddress(emailConfg.getUser()));
        message.addRecipient(Message.RecipientType.TO, new InternetAddress(to));
        message.setSubject(subject);

        // Create the message part
        BodyPart messageBodyPart = new MimeBodyPart();

        // Now set the actual message
        messageBodyPart.setText(content);

        // Create a multipar message
        Multipart multipart = new MimeMultipart();

        // Set text message part
        multipart.addBodyPart(messageBodyPart);

        // Part two is attachment
        messageBodyPart = new MimeBodyPart();
        DataSource source = new FileDataSource(filename);
        messageBodyPart.setDataHandler(new DataHandler(source));
        messageBodyPart.setFileName(filename);
        multipart.addBodyPart(messageBodyPart);

        // Send the complete message parts
        message.setContent(multipart);

        // Send message
        Transport.send(message);
        if(logger.isInfoEnabled()) logger.info("An email has been sent to " + to + " with subject " + subject);
    }
211362
public Future<Boolean> sendEmail(EmailBody body, String to, String title) {
        return sendEmail(body, to, title, null, null);
    }
1317689
def send_mail(to_list, sub, content, cc=None):
    '''
    
    '''
    sender = SMTP_CFG['name'] + "<" + SMTP_CFG['user'] + ">"
    msg = MIMEText(content, _subtype='html', _charset='utf-8')
    msg['Subject'] = sub
    msg['From'] = sender
    msg['To'] = ";".join(to_list)
    if cc:
        msg['cc'] = ';'.join(cc)
    try:
        # Using SMTP_SSL. The alinyun ECS has masked the 25 port since 9,2016.
        smtper = smtplib.SMTP_SSL(SMTP_CFG['host'], port=994)
        smtper.login(SMTP_CFG['user'], SMTP_CFG['pass'])
        smtper.sendmail(sender, to_list, msg.as_string())
        smtper.close()
        return True
    except:
        return False
548182
public Email cc(String... cc) {
		for (String c : cc) {
			cc(new EmailAddress(c));
		}
		return this;
	}