当前位置: 首页>>代码示例>>Java>>正文


Java MultiPartEmail.setAuthentication方法代码示例

本文整理汇总了Java中org.apache.commons.mail.MultiPartEmail.setAuthentication方法的典型用法代码示例。如果您正苦于以下问题:Java MultiPartEmail.setAuthentication方法的具体用法?Java MultiPartEmail.setAuthentication怎么用?Java MultiPartEmail.setAuthentication使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.commons.mail.MultiPartEmail的用法示例。


在下文中一共展示了MultiPartEmail.setAuthentication方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: sendEmailAttachment

import org.apache.commons.mail.MultiPartEmail; //导入方法依赖的package包/类
public void sendEmailAttachment(String email_to, String assunto, String msg, String file_logs) {
    File fileLogs = new File(file_logs);
    EmailAttachment attachmentLogs = new EmailAttachment();
    attachmentLogs.setPath(fileLogs.getPath());
    attachmentLogs.setDisposition(EmailAttachment.ATTACHMENT);
    attachmentLogs.setDescription("Logs");
    attachmentLogs.setName(fileLogs.getName());

    try {
        MultiPartEmail email = new MultiPartEmail();
        email.setDebug(debug);
        email.setHostName(smtp);
        email.addTo(email_to);
        email.setFrom(email_from);
        email.setAuthentication(email_from, email_password);
        email.setSubject(assunto);
        email.setMsg(msg);
        email.setSSL(true);
        email.attach(attachmentLogs);
        email.send();
    } catch (EmailException e) {
        System.out.println(e.getMessage());
    }
}
 
开发者ID:tiagorlampert,项目名称:sAINT,代码行数:25,代码来源:SendEmail.java

示例2: fillEmail

import org.apache.commons.mail.MultiPartEmail; //导入方法依赖的package包/类
/**
 * Fill email.
 *
 * @param email
 *            the email
 * @throws EmailException
 *             the email exception
 * @throws IOException
 *             Signals that an I/O exception has occurred.
 */
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 (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());
	}
}
 
开发者ID:kiswanij,项目名称:jk-util,代码行数:29,代码来源:MailInfo.java

示例3: newMail

import org.apache.commons.mail.MultiPartEmail; //导入方法依赖的package包/类
public MultiPartEmail newMail() {
    MultiPartEmail mail = new MultiPartEmail();

    mail.setHostName(host);
    if (!ssl)
        mail.setSmtpPort(port);
    else
        mail.setSslSmtpPort(valueOf(port));
    if (username != null && password != null)
        mail.setAuthentication(username, password);

    try {
        if (fromMail != null)
            mail.setFrom(fromMail);
    } catch (EmailException e) {
        throw new RuntimeException(e);
    }

    return mail;
}
 
开发者ID:kantega,项目名称:respiro,代码行数:21,代码来源:ServerConfig.java

示例4: prepareDirectMail

import org.apache.commons.mail.MultiPartEmail; //导入方法依赖的package包/类
/**
 * Prepares a eMail to be send direct over the mandator smtp configuration.
 * The email is missing: to, subject, message and optional attachments.
 *
 * @return the email
 * @throws EmailException if something is wrong in the subsystem.
 */
public MultiPartEmail prepareDirectMail() throws EmailException {
    MultiPartEmail email = new MultiPartEmail();
    email.setHostName(smtpConfiguration.getHostname());
    email.addBcc(company.getEmail());
    email.setFrom(company.getEmail(), company.getEmailName());
    email.setAuthentication(smtpConfiguration.getSmtpAuthenticationUser(), smtpConfiguration.getSmtpAuthenticationPass());
    email.setStartTLSEnabled(false);
    email.setSSLCheckServerIdentity(false);
    email.setSSLOnConnect(false);
    email.setCharset(smtpConfiguration.getCharset());
    return email;
}
 
开发者ID:gg-net,项目名称:dwoss,代码行数:20,代码来源:Mandator.java

示例5: sendSupportRequest

import org.apache.commons.mail.MultiPartEmail; //导入方法依赖的package包/类
public boolean sendSupportRequest() {
        try {
            String senderName = sender_name.getText();
            String senderEmail = sender_email.getText();
            String sendingTime = date_time.getText();
            String systemUser = system_user.getText();

            String message = messge_content.getText();

            if (message.isEmpty()) {
                JOptionPane.showMessageDialog(this, "You haven't entered your message. Please enter the message and try again.");
            }

            // Create the email message
            MultiPartEmail email = new MultiPartEmail();
            email.setHostName("mail.mdcc.lk");
            email.addTo("[email protected]", "Viraj @ MDCC");
            email.addTo("[email protected]", "Isuru @ MDCC");
            email.setFrom(senderEmail, senderName);
            email.setAuthentication("[email protected]", "mdccmail123");
            email.setSSLOnConnect(true);
            email.setStartTLSEnabled(true);
            email.setSmtpPort(465);

//            email.setHostName("mail.mdcc.lk");
//            email.addTo("[email protected]", "Isuru Ranawaka");
//            email.setFrom("[email protected]", "Isuru Ranawaka from MDCC");
//            email.setSubject("Test email with inline image");
//            email.setAuthentication("[email protected]", "=-88isuru");
//            email.setSSLOnConnect(false);
//            email.setSmtpPort(25);
//            email.setDebug(true);
            email.setSubject("New Support Request from Application");

            String textMessage = "Application - Support Request\n"
                    + "---------------------------------------------------------------------\n"
                    + "New Support Request from _P1_\n"
                    + "Sent by _P2_ on _P3_\n"
                    + "---------------------------------------------------------------------\n"
                    + "\n"
                    + "Message: \n_P4_\n"
                    + "\n"
                    + "---------------------------------------------------------------------\n"
                    + "This email was sent from Application. \n"
                    + "Please note that this is an automatically generated email and \n"
                    + "your replies will go nowhere.\n"
                    + "\n"
                    + "© All Rights Reserved - Management Development Co-operative Co. Ltd.";

            textMessage = textMessage.replace("_P1_", systemUser);
            textMessage = textMessage.replace("_P2_", senderName + "(" + senderEmail + ")");
            textMessage = textMessage.replace("_P3_", sendingTime);
            textMessage = textMessage.replace("_P4_", message);

            //attach file
            if (!attachedFile.trim().isEmpty()) {
                email.attach(new File(attachedFile));
            }
            
            // set the alternative message
            email.setMsg(textMessage);

            // send the email
            email.send();
            return true;
        } catch (Exception e) {
            JOptionPane.showMessageDialog(this, "Cannot send email.\nError:" + e.getLocalizedMessage(), "Sending failure", JOptionPane.ERROR_MESSAGE);
            return false;
        }
    }
 
开发者ID:isu3ru,项目名称:java-swing-template,代码行数:71,代码来源:Support.java


注:本文中的org.apache.commons.mail.MultiPartEmail.setAuthentication方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。