发送基本HTML邮件

@param mailContent
@return
@throws MessagingException
548027
public static void sendMail(MailContent mailContent) throws MessagingException {
        // 判断是否需要身份认证
        Properties pro = mailContent.getProperties();
        // 如果需要身份认证，则创建一个密码验证器
        AuthEntity authEntity = new MailUtil().new AuthEntity(mailContent.getAuthUsername(), mailContent.getAuthPassword());
        // 根据邮件会话属性和密码验证器构造一个发送邮件的session
        Session sendMailSession = Session.getDefaultInstance(pro, authEntity);
        // 根据session创建一个邮件消息
        Message mailMessage = new MimeMessage(sendMailSession);
        // 创建邮件发送者地址
        Address from = new InternetAddress(mailContent.getFromAddress());
        // 设置邮件消息的发送者
        mailMessage.setFrom(from);
        // 创建邮件的接收者地址，并设置到邮件消息中
        Address to = new InternetAddress(mailContent.getToAddress());
        // Message.RecipientType.TO属性表示接收者的类型为TO
        mailMessage.setRecipient(Message.RecipientType.TO, to);
        // 设置邮件消息的主题
        mailMessage.setSubject(mailContent.getSubject());
        // 设置邮件消息发送的时间
        mailMessage.setSentDate(new Date());
        // MiniMultipart类是一个容器类，包含MimeBodyPart类型的对象
        Multipart mainPart = new MimeMultipart();
        // 创建一个包含HTML内容的MimeBodyPart
        BodyPart html = new MimeBodyPart();
        // 设置HTML内容
        html.setContent(mailContent.getContent(), "text/html; charset=utf-8");
        mainPart.addBodyPart(html);
        // 将MiniMultipart对象设置为邮件内容
        mailMessage.setContent(mainPart);
        // 发送邮件
        Transport.send(mailMessage);
    }
79176
public String toHtml() {
        StringBuilder stringBuilder = new StringBuilder();

        stringBuilder
                .append("<p>")
                .append(objectNode.get(TYPE).asText()).append(": ")
                .append(objectNode.get(MESSAGE).asText()).append(" -> ")
                .append(objectNode.get(DETAILS).toString())
                .append("</p>");

        return stringBuilder.toString();
    }
940574
function(messageContent) {
                /**
                 * + InviteeVO       {object}
                 *    - id           {string}
                 *    - idType       {int}
                 */

                var inviteeData = {
                    id: messageContent.id,
                    idType: inviteeVOidTypes[messageContent.idType]
                };

                return inviteeData;
            }
910753
public HtmlEmailImpl setTextMsg(String aText) throws EmailException {
	if (StringUtil.isEmpty(aText)) {
	    throw new EmailException("Invalid message supplied");
	}
	this.text = aText;
	return this;
    }
812669
private Multipart buildContent(Charset charset) throws MessagingException {
		final Multipart mainPart = new MimeMultipart();

		// 正文
		final BodyPart body = new MimeBodyPart();
		body.setContent(content, StrUtil.format("text/{}; charset={}", isHtml ? "html" : "plain", charset));
		mainPart.addBodyPart(body);

		// 附件
		if (ArrayUtil.isNotEmpty(this.attachments)) {
			BodyPart bodyPart;
			for (DataSource attachment : attachments) {
				bodyPart = new MimeBodyPart();
				bodyPart.setDataHandler(new DataHandler(attachment));
				bodyPart.setFileName(InternalMailUtil.encodeText(attachment.getName(), charset));
				mainPart.addBodyPart(bodyPart);
			}
		}

		return mainPart;
	}
459420
public function createMessage($subject = null, $content = null, $html = true)
    {
        $class = $this->messageClass;

        $message = new $class($subject, $content, $html);

        $this->triggerEvent('onMailerAfterCreateMessage', [
            'message' => $message,
            'manager' => $this,
        ]);

        return $message;
    }
28658
public static boolean sendTextMail(MailSenderInfo mailInfo) {

        try {

            // 设置一些通用的数据
            Message mailMessage = setCommon(mailInfo);

            // 设置邮件消息的主要内容
            String mailContent = mailInfo.getContent();
            mailMessage.setText(mailContent);

            // 发送邮件
            Transport.send(mailMessage);

            return true;

        } catch (MessagingException ex) {

            ex.printStackTrace();
        }

        return false;
    }
17260
public static void sendMail(String to, String title, String content, String from, String key) throws Exception {
        setFrom(from);
        setKey(key);
        sendMail(to, title, content);
    }
464717
@Override
    public Set<URI> listMandatoryParts(URI messageContent) {
        if (messageContent == null || !messageContent.isAbsolute()) {
            log.warn("The Message Content URI is either absent or relative. Provide an absolute URI");
            return ImmutableSet.of();
        }

        URI graphUri;
        try {
            graphUri = getGraphUriForElement(messageContent);
        } catch (URISyntaxException e) {
            log.warn("The namespace of the URI of the message content is incorrect.", e);
            return ImmutableSet.of();
        }

        if (graphUri == null) {
            log.warn("Could not obtain a graph URI for the element. The URI may not be managed by the server - " + messageContent);
            return ImmutableSet.of();
        }

        String queryStr = new StringBuilder()
                .append("SELECT DISTINCT ?part WHERE { \n")
                .append(" GRAPH <").append(graphUri.toASCIIString()).append("> { \n")
                .append("<").append(messageContent.toASCIIString()).append("> ").append("<").append(MSM.hasMandatoryPart.getURI()).append(">").append(" ?part .")
                .append("?part ").append("<").append(RDF.type.getURI()).append(">").append(" ").append("<").append(MSM.MessagePart.getURI()).append("> .")
                .append(" } \n ")
                .append("} \n ")
                .toString();

        return this.graphStoreManager.listResourcesByQuery(queryStr, "part");
    }
659609
private static Message setCommon(MailSenderInfo mailInfo) throws MessagingException {

        //
        // 判断是否需要身份认证
        //
        MyAuthenticator authenticator = null;
        Properties pro = mailInfo.getProperties();
        if (mailInfo.isValidate()) {
            // 如果需要身份认证，则创建一个密码验证器
            authenticator = new MyAuthenticator(mailInfo.getUserName(), mailInfo.getPassword());
        }

        // 根据邮件会话属性和密码验证器构造一个发送邮件的session
        Session sendMailSession = Session.getDefaultInstance(pro, authenticator);

        // 根据session创建一个邮件消息
        Message mailMessage = new MimeMessage(sendMailSession);

        // 创建邮件发送者地址
        Address from = new InternetAddress(mailInfo.getFromAddress());

        // 设置邮件消息的发送者
        mailMessage.setFrom(from);

        // 创建邮件的接收者地址，并设置到邮件消息中
        Address to = new InternetAddress(mailInfo.getToAddress());
        mailMessage.setRecipient(Message.RecipientType.TO, to);

        // 设置邮件消息的主题
        mailMessage.setSubject(mailInfo.getSubject());

        // 设置邮件消息发送的时间
        mailMessage.setSentDate(new Date());

        return mailMessage;

    }
249281
public void sendHtmlMail(String from, String[] to, String title, String text)
            throws AddressException, MessagingException {

        long start = System.currentTimeMillis();

        MimeMessage mimeMessage = mailSender.createMimeMessage();
        MimeMessageHelper messageHelper = new MimeMessageHelper(mimeMessage, true, "GBK");

        InternetAddress[] toArray = new InternetAddress[to.length];
        for (int i = 0; i < to.length; i++) {
            toArray[i] = new InternetAddress(to[i]);
        }

        messageHelper.setFrom(new InternetAddress(from));
        messageHelper.setTo(toArray);
        messageHelper.setSubject(title);
        messageHelper.setText(text, true);
        mimeMessage = messageHelper.getMimeMessage();
        mailSender.send(mimeMessage);
        long end = System.currentTimeMillis();
        LOG.info("send mail start:" + start + " end :" + end);
    }
869317
public MailRequest newHtmlMailRequest(String subject, String body) {
        return createMailRequest(generateRequestId(), true, subject, body);
    }
503489
public String getContentString(Message message)
    {
        try {
            String strContentType = message.getContentType();
            Object content = message.getContent();
            if (content instanceof MimeMultipart)
            {
                for (int index = 0; ; index++)
                {
                    BodyPart bodyPart = ((javax.mail.internet.MimeMultipart)content).getBodyPart(index);
                    Object contents = bodyPart.getContent();
                    if (contents != null)
                        return contents.toString();
                }
            }
            return message.getContent().toString();     // pend(don) FIX THIS!
        } catch (IOException ex)    {
            ex.printStackTrace();
        } catch (MessagingException ex)    {
            ex.printStackTrace();
        }
        return null;
    }
621925
@Deprecated
    public MailBuilder content(net.sargue.mailgun.content.MailContent content) { //NOSONAR
        return text(content.text()).html(content.html());
    }
1358338
protected function _cacheContent()
    {
        // caching content if we can't fetch parts
        if ($this->_content === null && $this->_mail) {
            $this->_content = $this->_mail->getRawContent($this->_messageNum);
        }

        if (!$this->isMultipart()) {
            return;
        }

        // split content in parts
        $boundary = $this->getHeaderField('content-type', 'boundary');
        if (!$boundary) {
            /**
             * @see Zend_Mail_Exception
             */
            // require_once 'Zend/Mail/Exception.php';
            throw new Zend_Mail_Exception('no boundary found in content type to split message');
        }
        $parts = Zend_Mime_Decode::splitMessageStruct($this->_content, $boundary);
        if ($parts === null) {
            return;
        }
        $counter = 1;
        foreach ($parts as $part) {
            $this->_parts[$counter++] = new self(array('headers' => $part['header'], 'content' => $part['body']));
        }
    }
306573
public function html($content, $param = [], $config = [])
    {
        if ($param) {
            $content = strtr($content, $this->parseParam($param, $config));
        }
        $this->message->setBody($content, MailerConfig::CONTENT_HTML);

        return $this;
    }
5087
public AbstractMessageContentBuilder constructMessageBuilder(Element messageElement) {
        AbstractMessageContentBuilder messageBuilder = null;
        
        if (messageElement != null) {
            messageBuilder = parsePayloadTemplateBuilder(messageElement);
            
            if (messageBuilder == null) {
                messageBuilder = parseScriptBuilder(messageElement);
            }
        }

        if (messageBuilder == null) {
            messageBuilder = new PayloadTemplateMessageBuilder();
        }

        if (messageElement != null && messageElement.hasAttribute("name")) {
            messageBuilder.setMessageName(messageElement.getAttribute("name"));
        }

        return messageBuilder;
    }