本文整理汇总了Java中com.icegreen.greenmail.util.GreenMailUtil.newMimeMessage方法的典型用法代码示例。如果您正苦于以下问题:Java GreenMailUtil.newMimeMessage方法的具体用法?Java GreenMailUtil.newMimeMessage怎么用?Java GreenMailUtil.newMimeMessage使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.icegreen.greenmail.util.GreenMailUtil
的用法示例。
在下文中一共展示了GreenMailUtil.newMimeMessage方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: readDotTerminatedContent
import com.icegreen.greenmail.util.GreenMailUtil; //导入方法依赖的package包/类
/**
* Reads the contents of the stream until
* <CRLF>.<CRLF> is encountered.
* <p/>
* <p/>
* It would be possible and prehaps desirable to prevent the
* adding of an unnecessary CRLF at the end of the message, but
* it hardly seems worth 30 seconds of effort.
* </p>
*/
public void readDotTerminatedContent(BufferedReader in)
throws IOException {
_content = _workspace.getTmpFile();
Writer data = _content.getWriter();
PrintWriter dataWriter = new InternetPrintWriter(data);
while (true) {
String line = in.readLine();
if (line == null)
throw new EOFException("Did not receive <CRLF>.<CRLF>");
if (".".equals(line)) {
dataWriter.close();
break;
} else {
dataWriter.println(line);
}
}
try {
message = GreenMailUtil.newMimeMessage(_content.getAsString());
} catch (Exception e) {
throw new RuntimeException(e);
}
}
示例2: mimeMessage
import com.icegreen.greenmail.util.GreenMailUtil; //导入方法依赖的package包/类
/**
* Reads a MimeMessage encoded as a string literal from the request.
* TODO shouldn't need to read as a string and write out bytes
* use FixedLengthInputStream instead. Hopefully it can then be dynamic.
*
* @param request The Imap APPEND request
* @return A MimeMessage read off the request.
*/
public MimeMessage mimeMessage(ImapRequestLineReader request)
throws ProtocolException {
request.nextWordChar();
String mailString = consumeLiteral(request);
try {
return GreenMailUtil.newMimeMessage(mailString);
} catch (Exception e) {
throw new ProtocolException("UnexpectedException: " + e.getMessage());
}
}
示例3: readDotTerminatedContent
import com.icegreen.greenmail.util.GreenMailUtil; //导入方法依赖的package包/类
/**
* Reads the contents of the stream until
* <CRLF>.<CRLF> is encountered.
* <p/>
* <p/>
* It would be possible and perhaps desirable to prevent the
* adding of an unnecessary CRLF at the end of the message, but
* it hardly seems worth 30 seconds of effort.
* </p>
*/
public void readDotTerminatedContent(BufferedReader in)
throws IOException {
_content = _workspace.getTmpFile();
Writer data = _content.getWriter();
PrintWriter dataWriter = new InternetPrintWriter(data);
while (true) {
String line = in.readLine();
if (line == null)
throw new EOFException("Did not receive <CRLF>.<CRLF>");
if (".".equals(line)) {
dataWriter.close();
break;
} else if (line.startsWith(".")) {
dataWriter.println(line.substring(1));
} else {
dataWriter.println(line);
}
}
try {
message = GreenMailUtil.newMimeMessage(_content.getAsString());
} catch (Exception e) {
throw new RuntimeException(e);
}
}
示例4: mimeMessage
import com.icegreen.greenmail.util.GreenMailUtil; //导入方法依赖的package包/类
/**
* Reads a MimeMessage encoded as a string literal from the request.
* TODO shouldn't need to read as a string and write out bytes
* use FixedLengthInputStream instead. Hopefully it can then be dynamic.
*
* @param request The Imap APPEND request
* @return A MimeMessage read off the request.
*/
public MimeMessage mimeMessage(ImapRequestLineReader request)
throws ProtocolException {
request.nextWordChar();
byte[] mail = consumeLiteralAsBytes(request);
try {
return GreenMailUtil.newMimeMessage(new ByteArrayInputStream(mail));
} catch (Exception e) {
throw new ProtocolException("Can not create new mime message", e);
}
}
示例5: testMimeMessageLoading
import com.icegreen.greenmail.util.GreenMailUtil; //导入方法依赖的package包/类
@Test
public void testMimeMessageLoading() throws MessagingException {
MimeMessage message = GreenMailUtil.newMimeMessage(SAMPLE_EMAIL);
assertEquals("wassup", message.getSubject());
}
示例6: testGetBody
import com.icegreen.greenmail.util.GreenMailUtil; //导入方法依赖的package包/类
@Test
public void testGetBody() throws MessagingException, IOException {
MimeMessage message = GreenMailUtil.newMimeMessage(SAMPLE_EMAIL);
String body = GreenMailUtil.getBody(message);
assertEquals("Yo wassup Bertil", body.trim());
}
示例7: newMimeMessage
import com.icegreen.greenmail.util.GreenMailUtil; //导入方法依赖的package包/类
@Override
public MimeMessage newMimeMessage(final InputStream inputStream) {
return GreenMailUtil.newMimeMessage(inputStream);
}
示例8: createMailMessage
import com.icegreen.greenmail.util.GreenMailUtil; //导入方法依赖的package包/类
/**
* create mime message with given content
* @param mailString
* @return
* @throws MessagingException
*/
public MimeMessage createMailMessage(String mailString ) throws MessagingException {
return GreenMailUtil.newMimeMessage(mailString);
}