How to avoid do not reply verbiage in sendgrid - java

I am generating an email using sendgrid in my spring application . Everything is working fine but i am getting a verbiage below in the email saying like
"Do not reply to this message via e-mail. This address is automated and unattended"
Both FROM and TO are my organization ids .Is there anyway i can avoid that verbiage . Please help. Thanks.
Below is my email code
Value in emailContent is
"A new ticket has been created in your queue."
But the email i am receiving is
"A new ticket has been created in your queue. Do not reply to this message via e-mail. This address is automated and unattended."
Email from = new Email(fromDl);
Email to = new Email(toDl);
Content content = new Content("text/html", emailContent);
Mail mail = new Mail(from, subject, to, content);
SendGrid sg = new SendGrid(emailKey);
Request request = new Request();
request.setMethod(Method.POST);
request.setEndpoint("mail/send");
request.setBody(mail.build());
Response response = sg.api(request);

Normally SendGrid will not append anything to the contents of your email. However, you can set up an account level footer in your account mail settings.
To stop the appended content, remove the footer. Make sure that other emails you are sending don't miss out on that content too though.

Related

Mail headers missing via SMTP in office365

Here is peculiar case only found on office365 and not on outlook.com.
When I send email with a custom header set (X-ArchiveNum) via O365 SMTP. I am able to send email. But the receiver does not receive the headers when fetched via IMAP. This issue exists only with office365.
Transport transport = getTransport();
MimeMessage forward = new MimeMessage(getSession());
forward.addHeader("X-ArchiveNum", num);
forward.setSubject(sMessage.getSubject());
forward.setFrom(InternetAddress.parse(from)[0]);
forward.setText(body);
forward.saveChanges();
transport.sendMessage(forward, InternetAddress.parse(to));
I see the header being set, when I goto Sent Items folder in my outlook.office365.com account:
I also see the header on the browser when viewed from recipient account. But when I fetch the email via IMAP, I do not see it. I can see the other O365 related headers, but not mine.
Things work as expected from outlook.com (not O365)

sending an email from different address

I'm writing a program that has auto response in it. i.e. for example there is an user ad his email address would be user#domain.com, when ever someone writes an email to this address, there should be an auto response sent (Which I'm able to do it). but this should be sent from autoReply#domain.com(this is what I'm unable to know on how to do this). autoReply#domain.com is a shared mail box.
I'm using ews in my program and the below block of code is responsible to send the auto response.
private void replyToEmailWithURLs(ItemId itemId, List matchedKeyWords, String fromAddress) throws Exception {
EmailMessage message = EmailMessage.bind(service, itemId, new PropertySet(BasePropertySet.IdOnly));
ResponseMessage responseMessage = message.createReply(false);
message.getReplyTo().add(new EmailAddress("autoReply#domain.com"));
// Add autoReply in CC
responseMessage.getCcRecipients().add("autoReply#domain.com");
String responseUrls = getTheResponseUrlsFromJsonFile(matchedKeyWords, fromAddress);
responseMessage.setBodyPrefix(new MessageBody(BodyType.HTML, responseUrls));
responseMessage.sendAndSaveCopy();
message.setIsRead(true);
}
Here I tried to add a replyTo using message.getReplyTo().add(new EmailAddress("autoReply#domain.com"));, even this doesn't work.
I've seen a post here set reply-to address in outgoing email EWS , I was confused on the way it is working(basically given in c#), please let me know how can I get this done in Java.
Thanks
I'm not familiar with EWS, but apparently the standard JavaMail API supports setting From or the sender address.

Java Mail attachment not shown in outlook

we use Java Mail to send E-Mails with PDF attachments via SMTP over Lotus Notes to our customers.
Some time ago we got notified that serveral customers don't received an attachment.
One of these customers uses Microsoft Outlook and got an attachment flag in his inbox. But when he opens the
E-Mail, he doesn't see an attachment. We don't have the possibility to check the version of the E-Mail client's
and to do customer side test's, because our customers are worldwide located.
If our customer responds or (internal) forward the E-Mail, the attachment shown in receiver's E-Mail client.
The following part is the affected Java source code:
private static Multipart createMultipartMailWithAttachment(String messageText)
throws MessagingException {
// Message with attachments
Multipart mp = new MimeMultipart();
// Attach Text
MimeBodyPart mbp1 = new MimeBodyPart();
mbp1.setText(messageText, UTF8, HTML);
mp.addBodyPart(mbp1);
for (File f : attachments) {
MimeBodyPart fileAttachment = new MimeBodyPart();
try {
fileAttachment.setDisposition(MimeBodyPart.ATTACHMENT);
fileAttachment.attachFile(f);
if(f.getName().toLowerCase().endsWith(PDF_EXTENSION)) {
fileAttachment.setHeader(CONTENT_TYPE, APPLICATION_PDF);
}
} catch (IOException e) {
returnMessage = e.getMessage();
}
mp.addBodyPart(fileAttachment);
}
return mp;
}
We already tested different webmail services like gmail.com, yahoo.com and outlook.com. In every case the
attachment was shown. Also in an local installation of Mozilla Thunderbird, Microsoft Outlook or Lotus Notes
was the attachment shown.
After many inquiries we got many different solution processes. See setDisposition(MimeBodyPart.ATTACHMENT) and
setHeader(CONTENT_TYPE, APPLICATION_PDF). None of these solutions lead us to success. Does anyone know
a solution or a new solution process to solve that problem?
We had a similar problem where we sent file attachments from a J2EE application to various mail accounts. We utilized SMTP gmail server (smtp.gmail.com) with port 465 and HTTPS connection type for our outgoing messages.
Attachments to the messages sent via Java were not shown in Outlook but we could observe them in web interface for gmail accounts.
In our case, it turned out to be that MimeMultipart construction was not the correct one. We had
Multipart multipart = new MimeMultipart("alternative");
When we modified it to
Multipart multipart = new MimeMultipart();
the attachments became visible.
Please also refer to the following resource for a full explanation.
If messages sent from other mailers work properly and only messages sent from JavaMail fail, you'll need to examine the raw MIME content of the working and non-working messages to see what's different. You should be able to reproduce whatever content works using JavaMail.
There's lots of ways to access the raw MIME content of messages; let me know if you need help with that.
Obviously you'll need working and non-working examples messages with similar content to compare. If you have a repeatable test case - a message you can send to the same recipient multiple times and it fails every time - that would be most helpful.
I wanted to add a comment (question), but don't have the required points.
It could be a filter on the customer side that blocks attachments. See if the customer is getting a mail with attachment (same pdf) when sending it via normal outlook.
Second possible cause is the size of the attachment is a problem for the customer.
Third possible cause is that I have noticed that when I set up a rule to automatically put messages into a different folder, i see a message saying:
Links and other functionality have been disabled in this message. To turn on that functionality, move this message to the Inbox. Outlook blocked access to the potentially unsafe attachments: xxxx.pdf
Maybe this customer has setup a rule similarly.

This message uses a character set that is not supported by the InternetService?

I am using Spring JavaMailSender for sending mail from our web-application. Until now it works great, except for this case: one of our customers reported that their email client can't read the characters in email, and show:
This message uses a character set that is not supported by the
Internet Service. To view the original message content, open the
attached message. If the text doesn't display correctly, save the
attachment to disk, and then open it using a viewer that can display
the original character set.
The strange thing is that only one person see this error. Others see the emails just fine. The troubled user is using Hotmail.
I searched through several forums, most of them are about frustrated customers about their email clients, but there's not many solutions/work arounds for server side. Some say that it's because of an in-the-way SMTP server doesn't support Unicode, but I don't think it's the case...
Here's my (simplified) code:
MimeMessage mimeMessage = mailSender.createMimeMessage();
MimeMessageHelper helper = new MimeMessageHelper(mimeMessage, true);
helper.setFrom(new InternetAddress("abc#abc.abc","Hoang Long"));
helper.setReplyTo("abc#abc.abc");
helper.setTo(student.getEmail());
helper.setSubject(emailSubject);
helper.setCc(studioParameterService.getAllCCEmailAddress(studio.getId()));
helper.setSentDate(new Date());
helper.setText(emailContent, true);
for (String filePath : attachFileList) {
FileSystemResource attachFile = new FileSystemResource(filePath);
helper.addAttachment(attachFile.getFilename(), attachFile);
}
mailSender.send(helper.getMimeMessage());

why mail content is sent as attachment when I send it to Hotmail account?

why mail content is sent as attachment when I send it to Hotmail account?
When I send mail to a Hotmail account the body of the mail is sent as attachment. But when sent to other accounts like yahoomail, gmail it is not creating any problem.
I want to know why I am getting problem with Hotmail accounts.
Please give me a solution for this.
MimeMessage msg = createMimeMessage(sender, emsg,session,mail.companyName); Transport.send(msg);
Multipart multipart = new MimeMultipart();
// This is the template Attachment part
if (emsg.getAttachment() != null) {
for (File file : emsg.getAttachment()) {
MimeBodyPart messageAttachmentBodyPart = new MimeBodyPart();
messageAttachmentBodyPart = new MimeBodyPart();
DataSource source = new FileDataSource(file);
messageAttachmentBodyPart.setDataHandler(new DataHandler(source));
messageAttachmentBodyPart.setFileName(file.getName());
multipart.addBodyPart(messageAttachmentBodyPart);
}
}
Right. So, what happens if you send a file from a gmail account to a hotmail account, does it get attached? Or is it displayed just as you want? My guess is that attaching the file is a security measure to prevent malicious code from being activated on display. This mechanism might also be selective, meaning that it depends on the sender (an interesting post to read on this matter is this one).
Another thought: why is that a problem anyway?
Might help if you add
messageAttachmentBodyPart.setDisposition(Part.INLINE);

Categories