Home > Contents > Index >
Expanded TOC | Accordion TOC | Annotated TOC | Index
Utilities.sendMail
Sends an SMTP message to one or more recipients.
The
SendMail
method has a number of variants. The differences are as follows:
- sendMail (Variant 1) , which lets you specify both a MIME type and a character set.
- sendMail (Variant 2) , which lets you specify a MIME type. You accept the default character set.
- sendMail (Variant 3) , which forces you to accept the default MIME type and character set.
- sendMail (Variant 4) , which is the same as Variant 1 except that you provide an array of recipients.
- sendMail (Variant 5) , which is the same as Variant 2 except that you provide an array of recipients.
- sendMail (Variant 6) , which is the same as Variant 3 except that you provide an array of recipients.
To send mail, the Sites properties file must contain valid values for the
cs.emailhost
andcs.emailreturnto
properties.
Utilities.sendMail
Sends an STMP mail message, letting you designate a MIME type and a character set.
Syntax
public static final boolean sendMail(String from, String to, String subject, String replyto, String messagestr, String server, String contenttype, String charset, StringBuffer err)Parameters
from
- Specify the e-mail address of the sender.
to
- Specify the e-mail address of the recipient(s). If there are multiple recipients, use a comma to separate each e-mail address.
subject
- Specify the one-line summary (the subject) of the e-mail message.
replyto
- Specify the e-mail address to which the recipient should reply.
body
- Specify the e-mail message itself.
server
- Specify the name of the mail server that will send the message to the recipient.
contenttype
- Specify the MIME type of the body; for example,
text/plain
ortext/html
. Default istext/html
.
charset
- The character set for the
subject
. Popular values include:
- English: "
us-ascii
"- UTF-8:
"utf-8"
- Latin1: "
iso-8859-1
"- Japanese: "
iso-2022-jp
"err
- If there is a problem sending the message,
sendMail
returns errors here.
Returns
Returns
true
on success,false
on failure. Iffalse
is returned, examineerr
to determine the reason.Example
The following code sends a short e-mail message to two recipients:
String from = "frink@test.oracle.com"; String to = "lenny@qa.oracle.com, karl@qa.oracle.com"; String subject = "Iberian precipitation"; String replyto = "support@test.oracle.com"; String body = "The rain in Spain falls mainly on the plain."; String server = "mail1"; String contenttype = "text/plain"; String charset = "iso-8859-1"; StringBuffer err = new StringBuffer(); boolean result = Utilities.sendMail(from, to, subject, replyto, body, server, contenttype, charset, err); if (!result) { // Examine err }
Utilities.sendMail
Sends an STMP mail message, letting you designate a content type. Default character set is
UTF-8
.Syntax
public static final boolean sendMail(String from, String to, String subject, String replyto, String messagestr, String server, String contenttype, StringBuffer err)Parameters
from
- Specify the e-mail address of the sender.
to
- Specify the e-mail address of the recipient(s). If there are multiple recipients, use a comma to separate each e-mail address.
subject
- Specify the one-line summary (the subject) of the e-mail message.
replyto
- Specify the e-mail address to which the recipient should reply.
messagestr
- Specify the e-mail message itself.
server
- Specify the name of the mail server that will relay the message to the recipient.
contenttype
- Specify the MIME type of the message body; for example,
text/plain
ortext/html
. Default istext/html
.
err
- If there is a problem sending the message,
sendMail
returns errors here.
Returns
Returns
true
on success,false
on failure. Iffalse
is returned, examineerr
to determine the reason.
Utilities.sendMail
Sends an STMP mail message. The content type defaults to
text/html
. Default character set isUTF-8
.Syntax
public static final boolean sendMail(String from, String to, String subject, String replyto, String messagestr, String server, StringBuffer err)Parameters
from
- Specify the e-mail address of the sender.
to
- Specify the e-mail address of the recipient(s). If there are multiple recipients, use a comma to separate each e-mail address.
subject
- Specify the one-line summary (the subject) of the e-mail message.
replyto
- Specify the e-mail address to which the recipient should reply.
messagestr
- Specify the e-mail message itself.
server
- Specify the name of the mail server that will relay the message to the recipient.
err
- If there is a problem sending the message,
sendMail
returns errors here.
Returns
Returns
true
on success,false
on failure. Iffalse
is returned, examineerr
to determine the reason.
Utilities.sendMail
Sends an STMP mail message, letting you designate a MIME type and a character set. Specify an array of recipients.
Syntax
public static final boolean sendMail(String from, String to[], String subject, String replyto, String messagestr, String server, String contenttype, String charset, StringBuffer err)Parameters
from
- Specify the e-mail address of the sender.
to
- Specify the e-mail address of the recipient(s), each in a different cell of an array of strings.
subject
- Specify the one-line summary (the subject) of the e-mail message.
replyto
- Specify the e-mail address to which the recipient should reply.
body
- Specify the e-mail message itself.
server
- Specify the name of the mail server that will send the message to the recipient.
contenttype
- Specify the MIME type of the body; for example,
text/plain
ortext/html
. Default istext/html
.
charset
- The character set for the
subject
. Popular values include:
- English: "
us-ascii
"- UTF-8:
"utf-8"
- Latin1: "
iso-8859-1
"- Japanese: "
iso-2022-jp
"err
- If there is a problem sending the message,
sendMail
returns errors here.
Returns
Returns
true
on success,false
on failure. Iffalse
is returned, examineerr
to determine the reason.Example
The following code sends a short e-mail message to two recipients:
String from = "frink@test.oracle.com"; String[] to = new String[2]; to[0] = new String("lenny@qa.oracle.com"); to[1] = new String("karl@qa.oracle.com"); String subject = "Iberian precipitation"; String replyto = "support@test.oracle.com"; String body = "The rain in Spain falls mainly on the plain."; String server = "mail1"; String contenttype = "text/plain"; String charset = "iso-8859-1"; StringBuffer err = new StringBuffer(); boolean result = Utilities.sendMail(from, to, subject, replyto, body, server, contenttype, charset, err); if (!result) { // Examine err }
Utilities.sendMail
Sends an STMP mail message, letting you designate a content type. Default character set is
UTF-8
. Specify an array of recipients.Syntax
public static final boolean sendMail(String from, String to[], String subject, String replyto, String messagestr, String server, String contenttype, StringBuffer err)Parameters
from
- Specify the e-mail address of the sender.
to
- Specify the e-mail address of the recipient(s), each in a different cell of an array of strings.
subject
- Specify the one-line summary (the subject) of the e-mail message.
replyto
- Specify the e-mail address to which the recipient should reply.
messagestr
- Specify the e-mail message itself.
server
- Specify the name of the mail server that will relay the message to the recipient.
contenttype
- Specify the MIME type of the message body; for example,
text/plain
ortext/html
. Default istext/html
.
err
- If there is a problem sending the message,
sendMail
returns errors here.
Returns
Returns
true
on success,false
on failure. Iffalse
is returned, examineerr
to determine the reason.
Utilities.sendMail
Sends an STMP mail message. The content type defaults to
text/html
. Default character set isUTF-8
. Specify an array of recipients.Syntax
public static final boolean sendMail(String from, String to[], String subject, String replyto, String messagestr, String server, StringBuffer err)Parameters
from
- Specify the e-mail address of the sender.
to
- Specify the e-mail address of the recipient(s), each in a different cell of an array of strings.
subject
- Specify the one-line summary (the subject) of the e-mail message.
replyto
- Specify the e-mail address to which the recipient should reply.
messagestr
- Specify the e-mail message itself.
server
- Specify the name of the mail server that will relay the message to the recipient.
err
- If there is a problem sending the message,
sendMail
returns errors here.
Returns
Returns
true
on success,false
on failure. Iffalse
is returned, examineerr
to determine the reason.
Home > Contents > Index > ![]()
Oracle JAVA Reference
Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved.