Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
/*
* Copyright (c) 2024 Eclipse Dirigible contributors
*
* All rights reserved. This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v2.0 which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v20.html
*
* SPDX-FileCopyrightText: Eclipse Dirigible contributors SPDX-License-Identifier: EPL-2.0
*/
package org.eclipse.dirigible.components.api.mail;
import java.io.IOException;
import java.net.InetSocketAddress;
import java.net.Socket;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Properties;
import org.eclipse.angus.mail.smtp.SMTPSSLTransport;
import org.eclipse.angus.mail.smtp.SMTPTransport;
import com.google.gson.Gson;
import jakarta.activation.DataHandler;
import jakarta.mail.Authenticator;
import jakarta.mail.Message;
import jakarta.mail.MessagingException;
import jakarta.mail.PasswordAuthentication;
import jakarta.mail.Session;
import jakarta.mail.internet.ContentType;
import jakarta.mail.internet.InternetAddress;
import jakarta.mail.internet.MimeBodyPart;
import jakarta.mail.internet.MimeMessage;
import jakarta.mail.internet.MimeMultipart;
import jakarta.mail.util.ByteArrayDataSource;
/**
* The Class MailClient.
*/
public class MailClient {
/** The Constant MAIL_USER. */
// Mail properties
private static final String MAIL_USER = "mail.user";
/** The Constant MAIL_PASSWORD. */
private static final String MAIL_PASSWORD = "mail.password";
/** The Constant SMTP_TRANSPORT. */
private static final String SMTP_TRANSPORT = "smtp";
/** The Constant SMTPS_TRANSPORT. */
private static final String SMTPS_TRANSPORT = "smtps";
/** The properties. */
private final Properties properties;
/**
* Instantiates a new mail client.
*
* @param properties mail client configuration options
*/
public MailClient(Properties properties) {
this.properties = properties;
}
/**
* Send an email.
*
* @param from the sender
* @param to the to receiver
* @param cc the cc receiver
* @param bcc the bcc receiver
* @param subject the subject
* @param parts the mail parts
* @return the map
* @throws MessagingException the messaging exception
* @throws IOException Signals that an I/O exception has occurred.
*/
public Map send(String from, String[] to, String[] cc, String[] bcc, String subject, List