I'm trying to use an inline image in my thymeleaf template. Followed by this manual http://www.thymeleaf.org/doc/articles/springmail.html
For unknown reason image is not sent, i also didn't get any errors.
in template:
<img src="image_name.png" th:src="|cid:${imageResourceName}|"/>
sending email:
#Autowired
private JavaMailSender mailSender;
#Autowired
private SpringTemplateEngine templateEngine;
#Value(value = "classpath:templates/mails/listing/images/img11.png")
private Resource logoImageResource;
public boolean sendRichEmail(String receipient, EmailType emailType) {
EmailMessageConstructor emailMessageConstructor = new EmailMessageConstructor(emailType);
String recipientAddress = receipient;
String subject = emailMessageConstructor.getEmailTopic();
String from = "no-reply#xxx.com";
MimeMessage mimeMessage = mailSender.createMimeMessage();
MimeMessageHelper helper = null;
try {
helper = new MimeMessageHelper(mimeMessage, true, "utf-8");
final Context ctx = new Context();
ctx.setVariable("name", "User1");
ctx.setVariable("dateNow", new Date());
ctx.setVariable("dateExpired", MyUtils.addDays(new Date(), 30));
final String htmlContent = this.templateEngine.process(emailMessageConstructor.getEmailTemplate(), ctx);
mimeMessage.setContent(htmlContent, "text/html");
// Add the inline image, referenced from the HTML code as "cid:${imageResourceName}"
try {
String imageResourceName = logoImageResource.getFilename();
String imageContentType = new MimetypesFileTypeMap().getContentType(logoImageResource.getFile());
final InputStreamSource imageSource = new ByteArrayResource(IOUtils.toByteArray(logoImageResource.getInputStream()));
helper.addInline(imageResourceName, imageSource, imageContentType);
} catch (IOException e) {
e.printStackTrace();
}
helper.setTo(new InternetAddress(recipientAddress));
helper.setSubject(subject);
try {
helper.setFrom(new InternetAddress(from, "xxx"));
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
mailSender.send(mimeMessage);
} catch (MessagingException e) {
logger.error("Message creation exception: "+e.getMessage());
}
return true;
}
Want to use the image located in
/resources/templates/mails/listing/images/img11.png
Related
I've been constructing a software that will send an email verification code, however when ever I try to run it I get an error on this line ' newSession = Session.getInstance(properties,null);'
Does anyone knows why this is happening, and would also be willing to give me some pointers in how I could fix this?
public void emailVerification()
{
int min = 0;// sets a minimum number for range
int max = 9;//sets maximum number for range
int random_int = (int)Math.floor(Math.random()*(max-min+1)+min);// generates a random number
int random_int2 = (int)Math.floor(Math.random()*(max-min+1)+min);// generates another random number
int random_int3 = (int)Math.floor(Math.random()*(max-min+1)+min);// generates another random number
int random_int4 = (int)Math.floor(Math.random()*(max-min+1)+min);// generates the final random number
String randomDigit1 = random_int+"";
String randomDigit2 = random_int2+"";
String randomDigit3 = random_int3+"";
String randomDigit4 = random_int4+"";
allDigits = randomDigit1+randomDigit2+randomDigit3+randomDigit4;
Session newSession = null;
MimeMessage mimeMessage = null;
Properties properties = new Properties();
properties.put("mail.smtp.auth","true");
properties.put("mail.smtp.starttls.enable","true");
properties.put("mail.smtp.port","547");
String emailHost = ("smtp.gmail.com");
String myAccountEmail = ("**********#*****.com");
String myAccountPassword = ("*******");
newSession = Session.getInstance(properties,null);
String[] emailRecipients ={signUpAccount};
String emailSubject = "Verification Code";
String emailBody = allDigits;
mimeMessage = new MimeMessage(newSession);
for(int i =0; i<emailRecipients.length;i++)
{
try
{
mimeMessage.addRecipient(Message.RecipientType.TO,new InternetAddress(emailRecipients[i]));
}
catch (javax.mail.MessagingException me)
{
me.printStackTrace();
}
}
try
{
mimeMessage.setSubject(emailSubject);
}
catch (javax.mail.MessagingException me)
{
me.printStackTrace();
}
MimeMultipart multipart = new MimeMultipart();
MimeBodyPart bodyPart = new MimeBodyPart();
try
{
multipart.addBodyPart(bodyPart);
}
catch (javax.mail.MessagingException me)
{
me.printStackTrace();
}
try
{
mimeMessage.setContent(multipart);
}
catch (javax.mail.MessagingException me)
{
me.printStackTrace();
}
try
{
Transport transport = newSession.getTransport("smtp");
try
{
transport.connect(emailHost, myAccountEmail, myAccountPassword);
transport.sendMessage(mimeMessage, mimeMessage.getAllRecipients());
transport.close();
JOptionPane.showInputDialog("The verification Email has been sent");
}
catch (javax.mail.MessagingException me)
{
me.printStackTrace();
}
}
catch (javax.mail.NoSuchProviderException nspe)
{
nspe.printStackTrace();
}
}
The previous settings of port, authentication, and protocol are correct for you sending the email.
And as a result i get a message like the one in the image.
Without a message and without attachment, I just get the signature by default in the mail.
thanks;
#Autowired
public Session emailSession;
#Override
public JsonObject sendEmail(final JsonObject json) throws CommunicationsException {
final JsonObject response = new JsonObject();
final String receiver = (String) json.get(RECEIVER);
final String subject = (String) json.get(SUBJECT);
final String messageBody = (String) json.get(MESSAGE_BODY);
final String attachment = (String) json.get(ATTACHMENT);
try {
MimeMessage msg = new MimeMessage(emailSession);
msg.setFrom(new InternetAddress(MAIL_USER_FROM));
msg.addRecipient(Message.RecipientType.TO, new InternetAddress(receiver));
msg.setSubject(subject);
Multipart emailContenido = new MimeMultipart();
// Text
MimeBodyPart textoBodyPart = new MimeBodyPart();
textoBodyPart.setText(messageBody);
// Att
MimeBodyPart adjunto = new MimeBodyPart();
adjunto.attachFile("C:/hola.txt");
// Parts email
emailContenido.addBodyPart(textoBodyPart);
emailContenido.addBodyPart(adjunto);
msg.setContent(emailContenido);
Transport.send(msg);
System.out.println("Message ok");
} catch (MessagingException e) {
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return response;
}
I am trying to send email with created pdf document as the attachment, the environment i am working is the REST based java spring boot application,
Actually i know how to send email with the thymeleaf template engine, but how can i create a pdf document in memory, and send it as a attachment, this is the code that i am using for sending email.
Context cxt = new Context();
cxt.setVariable("doctorFullName", doctorFullName);
String message = templateEngine.process(mailTemplate, cxt);
emailService.sendMail(MAIL_FROM, TO_EMAIL,"Subject", "message");
and this this the sendmail() function
#Override
public void sendPdfMail(String fromEmail, String recipientMailId, String subject, String body) {
logger.info("--in the function of sendMail");
final MimeMessage mimeMessage = this.mailSender.createMimeMessage();
try {
final MimeMessageHelper message = new MimeMessageHelper(mimeMessage, true, "UTF-8");
message.setSubject(subject);
message.setFrom(fromEmail);
message.setTo(recipientMailId);
message.setText(body, true);
FileSystemResource file = new FileSystemResource("C:\\xampp\\htdocs\\project-name\\logs\\health360-logging.log");
message.addAttachment(file.getFilename(), file);
this.mailSender.send(mimeMessage);
logger.info("--Mail Sent Successfully");
} catch (MessagingException e) {
logger.info("--Mail Sent failed ---> " + e.getMessage());
throw new RuntimeException(e.getMessage());
}
}
Actually i need to create a kind of report with 2-3 pages as pdf file, and send in mail.
Also i need to send multiple pdf reports, in the mail, how can i do this, can you friends help me on this, i found something called jasper, is it something related to my environment,
This is how you can send a mail:
public void email() {
String smtpHost = "yourhost.com"; //replace this with a valid host
int smtpPort = 587; //replace this with a valid port
String sender = "sender#yourhost.com"; //replace this with a valid sender email address
String recipient = "recipient#anotherhost.com"; //replace this with a valid recipient email address
String content = "dummy content"; //this will be the text of the email
String subject = "dummy subject"; //this will be the subject of the email
Properties properties = new Properties();
properties.put("mail.smtp.host", smtpHost);
properties.put("mail.smtp.port", smtpPort);
Session session = Session.getDefaultInstance(properties, null);
ByteArrayOutputStream outputStream = null;
try {
//construct the text body part
MimeBodyPart textBodyPart = new MimeBodyPart();
textBodyPart.setText(content);
//now write the PDF content to the output stream
outputStream = new ByteArrayOutputStream();
writePdf(outputStream);
byte[] bytes = outputStream.toByteArray();
//construct the pdf body part
DataSource dataSource = new ByteArrayDataSource(bytes, "application/pdf");
MimeBodyPart pdfBodyPart = new MimeBodyPart();
pdfBodyPart.setDataHandler(new DataHandler(dataSource));
pdfBodyPart.setFileName("test.pdf");
//construct the mime multi part
MimeMultipart mimeMultipart = new MimeMultipart();
mimeMultipart.addBodyPart(textBodyPart);
mimeMultipart.addBodyPart(pdfBodyPart);
//create the sender/recipient addresses
InternetAddress iaSender = new InternetAddress(sender);
InternetAddress iaRecipient = new InternetAddress(recipient);
//construct the mime message
MimeMessage mimeMessage = new MimeMessage(session);
mimeMessage.setSender(iaSender);
mimeMessage.setSubject(subject);
mimeMessage.setRecipient(Message.RecipientType.TO, iaRecipient);
mimeMessage.setContent(mimeMultipart);
//send off the email
Transport.send(mimeMessage);
System.out.println("sent from " + sender +
", to " + recipient +
"; server = " + smtpHost + ", port = " + smtpPort);
} catch(Exception ex) {
ex.printStackTrace();
} finally {
//clean off
if(null != outputStream) {
try { outputStream.close(); outputStream = null; }
catch(Exception ex) { }
}
}
}
You can see that we create a MimeBodyPart with a DataSource created from bytes that resulted from a method named writePdf():
public void writePdf(OutputStream outputStream) throws Exception {
Document document = new Document();
PdfWriter.getInstance(document, outputStream);
document.open();
Paragraph paragraph = new Paragraph();
paragraph.add(new Chunk("hello!"));
document.add(paragraph);
document.close();
}
Since we use a ByteOutputStream instead of a FileOutputStream no file is written to disk.
I am trying to send email in background. Everything is working fine i am getting mail also but the problem is i am not getting email body and attachment in email.
I am not getting any error or any exception, i am getting mail also in my mail id but just the problem is attachment and email body, in attachment i am trying to send image from sdcard. So what is the problem in the following code. Can anyone help.
GMailSender.java
public class GMailSender extends javax.mail.Authenticator {
private String mailhost = "smtp.gmail.com";
private String user;
private String password;
private Session session;
private Multipart _multipart;
static {
Security.addProvider(new JSSEProvider());
}
public GMailSender(String user, String password) {
this.user = user;
this.password = password;
Properties props = new Properties();
props.setProperty("mail.transport.protocol", "smtp");
props.setProperty("mail.host", mailhost);
props.put("mail.smtp.auth", "true");
props.put("mail.smtp.port", "465");
props.put("mail.smtp.socketFactory.port", "465");
props.put("mail.smtp.socketFactory.class",
"javax.net.ssl.SSLSocketFactory");
props.put("mail.smtp.socketFactory.fallback", "false");
props.setProperty("mail.smtp.quitwait", "false");
session = Session.getDefaultInstance(props, this);
_multipart = new MimeMultipart();
}
protected PasswordAuthentication getPasswordAuthentication() {
return new PasswordAuthentication(user, password);
}
public synchronized void sendMail(String subject, String body,
String sender, String recipients) throws Exception {
MimeMessage message = new MimeMessage(session);
DataHandler handler = new DataHandler(new ByteArrayDataSource(
body.getBytes(), "text/plain"));
message.setSender(new InternetAddress(sender));
message.setSubject(subject);
message.setDataHandler(handler);
message.setContent(_multipart);
if (recipients.indexOf(',') > 0)
message.setRecipients(Message.RecipientType.TO,
InternetAddress.parse(recipients));
else
message.setRecipient(Message.RecipientType.TO, new InternetAddress(
recipients));
Transport.send(message);
}
public void addAttachment(String filename) throws Exception {
BodyPart messageBodyPart = new MimeBodyPart();
DataSource source = new FileDataSource(filename);
messageBodyPart.setDataHandler(new DataHandler(source));
messageBodyPart.setFileName(filename);
_multipart.addBodyPart(messageBodyPart);
}
public class ByteArrayDataSource implements DataSource {
private byte[] data;
private String type;
public ByteArrayDataSource(byte[] data, String type) {
super();
this.data = data;
this.type = type;
}
public ByteArrayDataSource(byte[] data) {
super();
this.data = data;
}
public void setType(String type) {
this.type = type;
}
public String getContentType() {
if (type == null)
return "application/octet-stream";
else
return type;
}
public InputStream getInputStream() throws IOException {
return new ByteArrayInputStream(data);
}
public String getName() {
return "ByteArrayDataSource";
}
public OutputStream getOutputStream() throws IOException {
throw new IOException("Not Supported");
}
}
}
JSSEProvider.java
public class JSSEProvider extends Provider {
private static final long serialVersionUID = 1L;
public JSSEProvider() {
super("HarmonyJSSE", 1.0, "Harmony JSSE Provider");
AccessController
.doPrivileged(new java.security.PrivilegedAction<Void>() {
public Void run() {
put("SSLContext.TLS",
"org.apache.harmony.xnet.provider.jsse.SSLContextImpl");
put("Alg.Alias.SSLContext.TLSv1", "TLS");
put("KeyManagerFactory.X509",
"org.apache.harmony.xnet.provider.jsse.KeyManagerFactoryImpl");
put("TrustManagerFactory.X509",
"org.apache.harmony.xnet.provider.jsse.TrustManagerFactoryImpl");
return null;
}
});
}
}
Activity.java
Button mButton = (Button) findViewById(R.id.button1);
mButton.setOnClickListener(new OnClickListener() {
#Override
public void onClick(View arg0) {
new sendEmail().execute();
}
});
and
public class sendEmail extends AsyncTask<Void, Void, String> {
#Override
protected String doInBackground(Void... params) {
try {
String subject = "Registration";
String message = "Thank you for regestering with";
String senderOfmail = "abcd#gmail.com";
String receiver = "abcd#gmail.com";
GMailSender sender = new GMailSender(
"abcd#gmail.com", "abcde12345");
sender.sendMail(subject, message, senderOfmail, receiver);
FileOutputStream outStream;
File file;
Bitmap bm = BitmapFactory.decodeResource(getResources(),
R.drawable.ic_launcher);
String extStorageDirectory = Environment
.getExternalStorageDirectory().toString();
file = new File(extStorageDirectory, "ic_launcher.PNG");
try {
outStream = new FileOutputStream(file);
bm.compress(Bitmap.CompressFormat.PNG, 100, outStream);
outStream.flush();
outStream.close();
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
try {
String fileName = file.toString().trim();
sender.addAttachment(fileName);
} catch (Exception e) {
Toast.makeText(Signup.this,
"There was a problem sending the email.",
Toast.LENGTH_LONG).show();
}
} catch (Exception e) {
Log.e("error", e.getMessage(), e);
return "Email Not Sent";
}
return "Email Sent";
}
}
Does anyone have an example of sending an email, with an attachment, via Amazon SES (in Java)?
Maybe a little bit late, but you can use this code (you also need Java Mail):
public class MailSender
{
private Transport AWSTransport;
...
//Initialize transport
private void initAWSTransport() throws MessagingException
{
String keyID = <your key id>
String secretKey = <your secret key>
MailAWSCredentials credentials = new MailAWSCredentials();
credentials.setCredentials(keyID, secretKey);
AmazonSimpleEmailService ses = new AmazonSimpleEmailServiceClient(credentials);
Properties props = new Properties();
props.setProperty("mail.transport.protocol", "aws");
props.setProperty("mail.aws.user", credentials.getAWSAccessKeyId());
props.setProperty("mail.aws.password", credentials.getAWSSecretKey());
AWSsession = Session.getInstance(props);
AWStransport = new AWSJavaMailTransport(AWSsession, null);
AWStransport.connect();
}
public void sendEmail(byte[] attachment)
{
//mail properties
String senderAddress = <Sender address>;
String recipientAddress = <Recipient address>;
String subject = <Mail subject>;
String text = <Your text>;
String mimeTypeOfText = <MIME type of text part>;
String fileMimeType = <MIME type of your attachment>;
String fileName = <Name of attached file>;
initAWSTransport();
try
{
// Create new message
Message msg = new MimeMessage(AWSsession);
msg.setFrom(new InternetAddress(senderAddress));
msg.addRecipient(Message.RecipientType.TO, new InternetAddress(recipientAddress));
msg.setSubject(subject);
//Text part
Multipart multipart = new MimeMultipart();
BodyPart messageBodyPart = new MimeBodyPart();
messageBodyPart.setContent(text, mimeTypeOfText);
multipart.addBodyPart(messageBodyPart);
//Attachment part
if (attachment != null && attachment.length != 0)
{
messageBodyPart = new MimeBodyPart();
DataSource source = new ByteArrayDataSource(attachment,fileMimeType);
messageBodyPart.setDataHandler(new DataHandler(source));
messageBodyPart.setFileName(fileName);
multipart.addBodyPart(messageBodyPart);
}
msg.setContent(multipart);
//send message
msg.saveChanges();
AWSTransport.sendMessage(msg, null);
} catch (MessagingException e){...}
}
}
Maybe a little bit late too.
Alternative to send mail using Java Mail and Amazon Raw Mail Sender
public static void sendMail(String subject, String message, byte[] attachement, String fileName, String contentType, String from, String[] to) {
try {
// JavaMail representation of the message
Session s = Session.getInstance(new Properties(), null);
MimeMessage mimeMessage = new MimeMessage(s);
// Sender and recipient
mimeMessage.setFrom(new InternetAddress(from));
for (String toMail : to) {
mimeMessage.addRecipient(javax.mail.Message.RecipientType.TO, new InternetAddress(toMail));
}
// Subject
mimeMessage.setSubject(subject);
// Add a MIME part to the message
MimeMultipart mimeBodyPart = new MimeMultipart();
BodyPart part = new MimeBodyPart();
part.setContent(message, MediaType.TEXT_HTML);
mimeBodyPart.addBodyPart(part);
// Add a attachement to the message
part = new MimeBodyPart();
DataSource source = new ByteArrayDataSource(attachement, contentType);
part.setDataHandler(new DataHandler(source));
part.setFileName(fileName);
mimeBodyPart.addBodyPart(part);
mimeMessage.setContent(mimeBodyPart);
// Create Raw message
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
mimeMessage.writeTo(outputStream);
RawMessage rawMessage = new RawMessage(ByteBuffer.wrap(outputStream.toByteArray()));
// Credentials
String keyID = "";// <your key id>
String secretKey = "";// <your secret key>
AWSCredentials credentials = new BasicAWSCredentials(keyID, secretKey);
AmazonSimpleEmailServiceClient client = new AmazonSimpleEmailServiceClient(credentials);
// Send Mail
SendRawEmailRequest rawEmailRequest = new SendRawEmailRequest(rawMessage);
rawEmailRequest.setDestinations(Arrays.asList(to));
rawEmailRequest.setSource(from);
client.sendRawEmail(rawEmailRequest);
} catch (IOException | MessagingException e) {
// your Exception
e.printStackTrace();
}
}
https://docs.aws.amazon.com/ses/latest/DeveloperGuide/send-email-raw.html has an example that sends both html and text bodies (with an attachment, of course). FWIW, here is the conversion and reorganization of its Java code to Kotlin. The dependency is 'com.sun.mail:javax.mail:1.6.2'.
data class Attachment(val fileName: String, val contentType: String, val data: ByteArray)
fun sendEmailWithAttachment(from: String, to: List<String>, subject: String, htmlBody: String, textBody: String,
attachment: Attachment) {
try {
val textPart = MimeBodyPart().apply {
setContent(textBody, "text/plain; charset=UTF-8")
}
val htmlPart = MimeBodyPart().apply {
setContent(htmlBody, "text/html; charset=UTF-8")
}
// Create a multipart/alternative child container.
val childPart = MimeMultipart("alternative").apply {
// Add the text and HTML parts to the child container.
addBodyPart(textPart)
addBodyPart(htmlPart)
}
// Create a wrapper for the HTML and text parts.
val childWrapper = MimeBodyPart().apply {
setContent(childPart)
}
// Define the attachment
val dataSource = ByteArrayDataSource(attachment.data, attachment.contentType)
// val dataSource = FileDataSource(filePath) // if using file directly
val attPart = MimeBodyPart().apply {
dataHandler = DataHandler(dataSource)
fileName = attachment.fileName
}
// Create a multipart/mixed parent container.
val parentPart = MimeMultipart("mixed").apply {
// Add the multipart/alternative part to the message.
addBodyPart(childWrapper)
addBodyPart(attPart) // Add the attachment to the message.
}
// JavaMail representation of the message
val s = Session.getDefaultInstance(Properties())
val mimeMessage = MimeMessage(s).apply {
// Add subject, from and to lines
this.subject = subject
setFrom(InternetAddress(from))
to.forEach() {
addRecipient(javax.mail.Message.RecipientType.TO, InternetAddress(it))
}
// Add the parent container to the message.
setContent(parentPart)
}
// Create Raw message
val rawMessage = with(ByteArrayOutputStream()) {
mimeMessage.writeTo(this)
RawMessage(ByteBuffer.wrap(this.toByteArray()))
}
val rawEmailRequest = SendRawEmailRequest(rawMessage).apply {
source = from
setDestinations(to)
}
// Send Mail
val client = AmazonSimpleEmailServiceClientBuilder.standard()
.withRegion(Regions.US_EAST_1).build()
client.sendRawEmail(rawEmailRequest)
println("Email with attachment sent to $to")
} catch (e: Exception) {
println(e)
}
}
Here is an updated, cleaned up version with logging and check for production.
public void sendEmail(String to, String subject, String body, String attachment, String mimeType, String fileName) {
if (to == null) return;
String environment = System.getProperty("ENVIRONMENT", System.getenv("ENVIRONMENT"));
String logMessage;
if (environment != null && environment.equals("production")) {
logMessage = "Sent email to " + to + ".";
} else {
to = "success#simulator.amazonses.com";
logMessage = "Email sent to success#simulator.amazonses.com because $ENVIRONMENT != 'production'";
}
// https://docs.aws.amazon.com/ses/latest/DeveloperGuide/examples-send-raw-using-sdk.html
Session session = Session.getDefaultInstance(new Properties());
MimeMessage message = new MimeMessage(session);
try {
message.setSubject(subject, "UTF-8");
message.setFrom(new InternetAddress(FROM));
message.setRecipients(javax.mail.Message.RecipientType.TO, InternetAddress.parse(to));
MimeMultipart msg = new MimeMultipart("mixed");
MimeBodyPart wrap = new MimeBodyPart();
MimeMultipart msgBody = new MimeMultipart("alternative");
MimeBodyPart textPart = new MimeBodyPart();
MimeBodyPart htmlPart = new MimeBodyPart();
textPart.setContent(body, "text/plain; charset=UTF-8");
htmlPart.setContent(body,"text/html; charset=UTF-8");
msgBody.addBodyPart(textPart);
msgBody.addBodyPart(htmlPart);
wrap.setContent(msgBody);
msg.addBodyPart(wrap);
MimeBodyPart att = new MimeBodyPart();
att.setDataHandler(new DataHandler(attachment, mimeType));
att.setFileName(fileName);
// DataSource fds = new FileDataSource(attachment);
// att.setDataHandler(new DataHandler(fds));
// att.setFileName(fds.getName());
msg.addBodyPart(att);
message.setContent(msg);
AmazonSimpleEmailService client = AmazonSimpleEmailServiceClientBuilder
.standard().withRegion(Regions.US_EAST_1).build();
message.writeTo(System.out);
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
message.writeTo(outputStream);
RawMessage rawMessage = new RawMessage(ByteBuffer.wrap(outputStream.toByteArray()));
SendRawEmailRequest rawEmailRequest = new SendRawEmailRequest(rawMessage);
// .withConfigurationSetName(CONFIGURATION_SET);
client.sendRawEmail(rawEmailRequest);
Logger.info(this.getClass(), "sendEmail()", logMessage);
} catch (Exception ex) {
Logger.info(this.getClass(), "sendEmail()", "The email was not sent. Error: " + ex.getMessage());
}
}
https://docs.aws.amazon.com/ses/latest/DeveloperGuide/examples-send-raw-using-sdk.html
You use a shared credentials file to pass your AWS access key ID and secret access key. As an alternative to using a shared credentials file, you can specify your AWS access key ID and secret access key by setting two environment variables (AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY, respectively).