Class SmtpEmailSender
java.lang.Object
com.google.gerrit.server.mail.send.SmtpEmailSender
- All Implemented Interfaces:
EmailSender
Sends email via a nearby SMTP server.
Doesn't support including EmailResource in the payload.
-
Nested Class Summary
Nested Classes -
Method Summary
Modifier and TypeMethodDescriptionprotected String
buildMultipartBody
(String boundary, String textPart, String htmlPart) boolean
Can the address receive messages from us?static String
generateMultipartBoundary
(String textBody, String htmlBody) boolean
protected String
quotedPrintableEncode
(String input) void
send
(Address from, Collection<Address> rcpt, Map<String, EmailHeader> callerHeaders, String body) Sends an email message with a text body only (i.e.void
send
(Address from, Collection<Address> rcpt, Map<String, EmailHeader> callerHeaders, String textBody, String htmlBody) Sends an email message.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface com.google.gerrit.server.mail.send.EmailSender
send
-
Method Details
-
isEnabled
public boolean isEnabled()- Specified by:
isEnabled
in interfaceEmailSender
-
canEmail
Description copied from interface:EmailSender
Can the address receive messages from us?- Specified by:
canEmail
in interfaceEmailSender
- Parameters:
address
- the address to consider.- Returns:
- true if this sender will deliver to the address.
-
send
public void send(Address from, Collection<Address> rcpt, Map<String, EmailHeader> callerHeaders, String body) throws com.google.gerrit.exceptions.EmailExceptionDescription copied from interface:EmailSender
Sends an email message with a text body only (i.e. not HTML or multipart).Authors of new implementations of this interface should not use this method to send a message because this method does not accept the HTML body. Instead, authors should use the above signature of
send
.This version of the method is preserved for support of legacy implementations.
- Specified by:
send
in interfaceEmailSender
- Parameters:
from
- who the message is from.rcpt
- one or more address where the message will be delivered to. This list overrides any To or CC headers inheaders
.callerHeaders
- message headers.body
- text to appear in the body of the message.- Throws:
com.google.gerrit.exceptions.EmailException
- the message cannot be sent.
-
send
public void send(Address from, Collection<Address> rcpt, Map<String, EmailHeader> callerHeaders, String textBody, String htmlBody) throws com.google.gerrit.exceptions.EmailExceptionDescription copied from interface:EmailSender
Sends an email message. Messages always contain a text body, but messages can optionally include an additional HTML body. If both body types are present,send
should construct amultipart/alternative
message with an appropriately-selected boundary.- Specified by:
send
in interfaceEmailSender
- Parameters:
from
- who the message is from.rcpt
- one or more address where the message will be delivered to. This list overrides any To or CC headers inheaders
.callerHeaders
- message headers.textBody
- text to appear in thetext/plain
body of the message.htmlBody
- optional HTML code to appear in thetext/html
body of the message.- Throws:
com.google.gerrit.exceptions.EmailException
- the message cannot be sent.
-
generateMultipartBoundary
public static String generateMultipartBoundary(String textBody, String htmlBody) throws com.google.gerrit.exceptions.EmailException - Throws:
com.google.gerrit.exceptions.EmailException
-
buildMultipartBody
protected String buildMultipartBody(String boundary, String textPart, String htmlPart) throws IOException - Throws:
IOException
-
quotedPrintableEncode
- Throws:
IOException
-