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


Java NoSuchProviderException类代码示例

本文整理汇总了Java中javax.mail.NoSuchProviderException的典型用法代码示例。如果您正苦于以下问题:Java NoSuchProviderException类的具体用法?Java NoSuchProviderException怎么用?Java NoSuchProviderException使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: sendMessage

import javax.mail.NoSuchProviderException; //导入依赖的package包/类
public void sendMessage (Message oMsg,
                         Address[] aAdrFrom, Address[] aAdrReply,
                         Address[] aAdrTo, Address[] aAdrCc, Address[] aAdrBcc)
  throws NoSuchProviderException,SendFailedException,ParseException,
         MessagingException,NullPointerException {           	
  oMsg.addFrom(aAdrFrom);
  if (null==aAdrReply)
    oMsg.setReplyTo(aAdrReply);
  else
    oMsg.setReplyTo(aAdrFrom);
  if (aAdrTo!=null) oMsg.addRecipients(javax.mail.Message.RecipientType.TO, aAdrTo);
  if (aAdrCc!=null) oMsg.addRecipients(javax.mail.Message.RecipientType.CC, aAdrCc);
  if (aAdrBcc!=null) oMsg.addRecipients(javax.mail.Message.RecipientType.BCC, aAdrBcc);
  oMsg.setSentDate(new java.util.Date());
  Transport.send(oMsg);
}
 
开发者ID:sergiomt,项目名称:zesped,代码行数:17,代码来源:MailSessionHandler.java

示例2: markMessagesAsRead

import javax.mail.NoSuchProviderException; //导入依赖的package包/类
public void markMessagesAsRead(String[] ids, boolean seen) throws NoSuchProviderException, MessagingException, IOException {
  IMAPFolder folder = (IMAPFolder)getStore().getFolder("Inbox");
  folder.open(Folder.READ_WRITE);
  UIDFolder uidFolder = folder;
  
  Message[] msgs;
  

  long[] uids = new long[ids.length];
  int i = 0;
  for (String s : ids) {
    try {
      uids[i++] = Long.parseLong(s);
    } catch (Exception ex) {
      Log.d("rgai", "", ex);
    }
  }
  // TODO: if instance not support UID, then use simple id
  msgs = uidFolder.getMessagesByUID(uids);

  folder.setFlags(msgs, new Flags(Flags.Flag.SEEN), seen);

  folder.close(false);
}
 
开发者ID:k-kojak,项目名称:yako,代码行数:25,代码来源:SimpleEmailMessageProvider.java

示例3: run

import javax.mail.NoSuchProviderException; //导入依赖的package包/类
@Override
public void run() {
    //we only need to send the message so we use smtps
    try (Transport transport = session.getTransport()) {
        EmailConfiguration emailConfig = plugin.getConfigManager().getGeneral().getEmail();

        //connect to host and send message
        if (!transport.isConnected()) {
            String password = emailConfig.getPassword();
            transport.connect(emailConfig.getHost(), emailConfig.getAccount(), password);
        }

        transport.sendMessage(email, email.getAllRecipients());
        player.sendMessage(plugin.getConfigManager().getText().getMailSent());
    } catch (NoSuchProviderException providerEx) {
        plugin.getLogger().error("Transport provider not found", providerEx);
        plugin.getLogger().error("Registered providers: {}", Arrays.asList(session.getProviders()));

        player.sendMessage(plugin.getConfigManager().getText().getErrorCommand());
    } catch (MessagingException messagingEx) {
        plugin.getLogger().error("Error sending email", messagingEx);
        player.sendMessage(plugin.getConfigManager().getText().getErrorCommand());
    }
}
 
开发者ID:games647,项目名称:FlexibleLogin,代码行数:25,代码来源:SendMailTask.java

示例4: init

import javax.mail.NoSuchProviderException; //导入依赖的package包/类
@PostConstruct
public void init() {
	if (session == null) {
		throw new IllegalStateException("JavaMail session is null.");
	}
	javaMailSessionDelegate = new JavaMailSessionDelegate() {
		@Override
		public Transport findTransport(String protocolToUse) throws NoSuchProviderException {
			return session.getTransport(protocolToUse);
		}
		@Override
		public MimeMessage createMimeMessage(InputStream inputStream) throws MessagingException {
			return new MimeMessage(session, inputStream);
		}
	};
}
 
开发者ID:m-szalik,项目名称:javamail,代码行数:17,代码来源:JMS2JavaMail.java

示例5: EmailDownloaderDialog

import javax.mail.NoSuchProviderException; //导入依赖的package包/类
public EmailDownloaderDialog(java.awt.Frame parent, boolean modal,
        final Case aCase, final EmailConfiguration emailConfiguration) throws SQLException, NoSuchProviderException, MessagingException, IOException, Exception {
    super(parent, modal);
    
    initComponents();
    setLocationRelativeTo(parent);        
    
    this.DownloadProgressBar.setIndeterminate(true);
    this.aCase = aCase;
    this.emailConfiguration = emailConfiguration;
    
    this.onlineEmailDownloader = new OnlineEmailDownloader(this,
        this.aCase.getCaseLocation() + "\\" + ApplicationConstants.CASE_ONLINE_EMAIL_ATTACHMENTS_FOLDER,
        this.aCase.getCaseLocation() + "\\" + ApplicationConstants.CASE_EMAIL_DB_FOLDER,
        this.aCase.getCaseLocation() + "\\" + ApplicationConstants.CASE_ARCHIVE_FOLDER
        );
}
 
开发者ID:CoEIA,项目名称:DEM,代码行数:18,代码来源:EmailDownloaderDialog.java

示例6: testJavaMailProperties

import javax.mail.NoSuchProviderException; //导入依赖的package包/类
public void testJavaMailProperties() throws MessagingException {
	Properties props = new Properties();
	props.setProperty("bogusKey", "bogusValue");
	MockJavaMailSender sender = new MockJavaMailSender() {
		@Override
		protected Transport getTransport(Session sess) throws NoSuchProviderException {
			assertEquals("bogusValue", sess.getProperty("bogusKey"));
			return super.getTransport(sess);
		}
	};
	sender.setJavaMailProperties(props);
	sender.setHost("host");
	sender.setUsername("username");
	sender.setPassword("password");

	MimeMessage mimeMessage = sender.createMimeMessage();
	mimeMessage.setRecipient(Message.RecipientType.TO, new InternetAddress("[email protected]"));
	sender.send(mimeMessage);

	assertEquals("host", sender.transport.getConnectedHost());
	assertEquals("username", sender.transport.getConnectedUsername());
	assertEquals("password", sender.transport.getConnectedPassword());
	assertTrue(sender.transport.isCloseCalled());
	assertEquals(1, sender.transport.getSentMessages().size());
	assertEquals(mimeMessage, sender.transport.getSentMessage(0));
}
 
开发者ID:deathspeeder,项目名称:class-guard,代码行数:27,代码来源:JavaMailSenderTests.java

示例7: retrieveMail

import javax.mail.NoSuchProviderException; //导入依赖的package包/类
private void retrieveMail() throws NoSuchProviderException,
        MessagingException, IOException {
    Properties properties = new Properties();
    Session session = Session.getInstance(properties);
    Store store =
            session.getStore(new URLName("pop3://john:[email protected]:"
                    + PORT_POP + "/INBOX"));
    store.connect();
    Folder folder = store.getFolder("INBOX");
    folder.open(Folder.READ_WRITE);
    Message[] messages = folder.getMessages();
    assertEquals(1, messages.length);
    Message message = messages[0];
    assertEquals("Hello World!\r\n", message.getContent());
    message.setFlag(Flags.Flag.DELETED, true);
    folder.close(true);
    store.close();
}
 
开发者ID:hontvari,项目名称:mireka,代码行数:19,代码来源:MxPopTest.java

示例8: getStore

import javax.mail.NoSuchProviderException; //导入依赖的package包/类
/**
 * Connects to imap, returns a store.
 * 
 * @return the store where, where you can read the emails
 * @throws NoSuchProviderException
 * @throws MessagingException
 * @throws AuthenticationFailedException 
 */
private synchronized Store getStore() throws NoSuchProviderException, MessagingException, AuthenticationFailedException {
  Properties props = System.getProperties();
  this.setProperties(props);
  Session session = Session.getDefaultInstance(props, null);
  Store store;
  if (this.account.isSsl()) {
    store = session.getStore("imaps");
  } else {
    store = session.getStore("imap");
  }
  Log.d("rgai3", "connecting with account: " + account);
  store.connect(account.getImapAddress(), account.getEmail(), account.getPassword());
  
  return store;
}
 
开发者ID:k-kojak,项目名称:yako,代码行数:24,代码来源:SimpleEmailMessageProvider.java

示例9: markMessageAsRead

import javax.mail.NoSuchProviderException; //导入依赖的package包/类
@Override
public void markMessageAsRead(String id, boolean seen) throws NoSuchProviderException, MessagingException, IOException {
  
  IMAPFolder folder = (IMAPFolder)getStore().getFolder("Inbox");
  folder.open(Folder.READ_WRITE);
  UIDFolder uidFolder = (UIDFolder)folder;
  
  Message ms = uidFolder.getMessageByUID(Long.parseLong(id));

  if (ms != null) {
    ms.setFlag(Flags.Flag.SEEN, seen);
  }
  folder.close(false);
}
 
开发者ID:k-kojak,项目名称:yako,代码行数:15,代码来源:SimpleEmailMessageProvider.java

示例10: deleteMessage

import javax.mail.NoSuchProviderException; //导入依赖的package包/类
public void deleteMessage(String id) throws NoSuchProviderException, MessagingException, IOException {
  IMAPFolder folder = (IMAPFolder)getStore().getFolder("Inbox");
  folder.open(Folder.READ_WRITE);
  UIDFolder uidFolder = (UIDFolder)folder;
  
  Message ms = uidFolder.getMessageByUID(Long.parseLong(id));

  if (ms != null) {
    ms.setFlag(Flags.Flag.DELETED, true);
  }
  folder.close(true);
}
 
开发者ID:k-kojak,项目名称:yako,代码行数:13,代码来源:SimpleEmailMessageProvider.java

示例11: sendMessage

import javax.mail.NoSuchProviderException; //导入依赖的package包/类
private void sendMessage() throws NoSuchProviderException, MessagingException, IOException {
    props = PropertiesReader.getProps();

    props.list(System.out);
    System.out.println("\n========message follows==========\n");
    session = Session.getInstance(props);
    session.setDebug(true);
    message = new MimeMessage(session);
    String host = props.getProperty("mail.smtp.host");
    String user = props.getProperty("mail.smtp.user");
    String password = props.getProperty("mail.smtp.password");
    int port = Integer.parseInt(props.getProperty("mail.smtp.port"));
    System.out.println(host + user + password + port);
    message.setFrom(new InternetAddress(props.getProperty("mail.smtp.user")));
    message.setRecipients(Message.RecipientType.TO, InternetAddress.parse(props.getProperty("mail.smtp.user"), false));
    message.setText("hello gmail");
    System.out.println(message.getFrom().toString());
    System.out.println(message.getRecipients(Message.RecipientType.TO).toString());
    System.out.println(message.getContent().toString());
    transport = (SMTPTransport) session.getTransport("smtp");
    System.out.println("trying...");
    transport.connect(host, port, user, password);
    System.out.println("...connected");
    transport.sendMessage(message, message.getAllRecipients());
    transport.close();
}
 
开发者ID:THUFIR,项目名称:MailFromNNTP,代码行数:27,代码来源:Gmail.java

示例12: sendMessage

import javax.mail.NoSuchProviderException; //导入依赖的package包/类
private void sendMessage() throws NoSuchProviderException, MessagingException, IOException {
    final Properties props = PropertiesReader.getProps();
    props.list(System.out);
    System.out.println("\n========message follows==========\n");
    Session session = Session.getInstance(props,
            new javax.mail.Authenticator() {

                @Override
                protected PasswordAuthentication getPasswordAuthentication() {
                    return new PasswordAuthentication(props.getProperty("mail.smtp.username"), props.getProperty("mail.smtp.password"));
                }
            });
    try {
        Message message = new MimeMessage(session);
        message.setFrom(new InternetAddress(props.getProperty("mail.smtp.username")));
        message.setRecipients(Message.RecipientType.TO, InternetAddress.parse(props.getProperty("mail.smtp.username")));
        message.setSubject("Testing Subject");
        message.setText("Dear Google,\n\n please accept this authenticator.");
        Transport.send(message);
        System.out.println("Done");

    } catch (MessagingException e) {
        throw new RuntimeException(e);
    }
}
 
开发者ID:THUFIR,项目名称:MailFromNNTP,代码行数:26,代码来源:SendTLS.java

示例13: main

import javax.mail.NoSuchProviderException; //导入依赖的package包/类
public static void main(String[] args) throws IOException, NoSuchProviderException, MessagingException {

        Properties properties = new Properties();
        properties.load(new InputStreamReader(
                    ClassLoader.class.getResourceAsStream("/account.properties"), "UTF-8"));

        final String HOST = properties.getProperty("HOST");
        final String PORT = properties.getProperty("PORT");
        final String USER = properties.getProperty("USER");
        final String PASSWORD = properties.getProperty("PASSWORD");

        System.out.println(properties);

        Security.addProvider(new com.sun.net.ssl.internal.ssl.Provider());

        Properties gmailProperties = new Properties();
        gmailProperties.put("mail.imap.starttls.enable","true");
        gmailProperties.put("mail.imap.auth", "true");
        gmailProperties.put("mail.imap.socketFactory.port", PORT);
        gmailProperties.put("mail.imap.socketFactory.class", "javax.net.ssl.SSLSocketFactory");
        gmailProperties.put("mail.imap.socketFactory.fallback", "false");

        Session session = Session.getDefaultInstance(gmailProperties, null);
        Store store = session.getStore("imap");
        store.connect(HOST, USER, PASSWORD);

        Folder folder = store.getFolder(properties.getProperty("LABEL"));
        folder.open(Folder.READ_ONLY);

        for (Message message : folder.getMessages()) {
            System.out.printf("Subject: %s\n", message.getSubject());
            System.out.printf("Received Date: %s\n", message.getReceivedDate());

            System.out.printf("Content:\n%s\n", getText(message.getContent()));
        }

        folder.close(false);
    }
 
开发者ID:mikoto2000,项目名称:MiscellaneousStudy,代码行数:39,代码来源:GetMail.java

示例14: senderConnect

import javax.mail.NoSuchProviderException; //导入依赖的package包/类
public void senderConnect() throws NoSuchProviderException, MessagingException {
    senderSession = Session.getInstance(pManager.getSenderProps());
    //senderSession.setDebugOut(pManager.get_Log_Stream());
    
    transport = (SMTPTransport)(senderSession.getTransport("smtp"));
    transport.connect(pManager.get_SENDER_User(), pManager.get_SENDER_Pass());
}
 
开发者ID:adbenitez,项目名称:MailCopier,代码行数:8,代码来源:MailCopier.java

示例15: receiverConnect

import javax.mail.NoSuchProviderException; //导入依赖的package包/类
public void receiverConnect() throws NoSuchProviderException, MessagingException {
    receiverSession = Session.getInstance(pManager.getReceiverProps());
    //receiverSession.setDebugOut(pManager.get_Log_Stream());
    
    store = receiverSession.getStore(pManager.get_RECEIVER_Protocol());
    store.connect(pManager.get_RECEIVER_User(), pManager.get_RECEIVER_Pass());
}
 
开发者ID:adbenitez,项目名称:MailCopier,代码行数:8,代码来源:MailCopier.java


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