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)
Related
DocuSign is not sending email to Signer.
I have even followed below support link. I did not find any proper solution.
https://support.docusign.com/answers/00002292
while creating envelope I am using below code
Signer signer = new Signer();
signer.setEmail("***#gmail.com");
signer.setName("My Name");
and for generating URL for Iframe
RecipientViewRequest returnUrl = new RecipientViewRequest();
returnUrl.setReturnUrl("https://www.docusign.com/devcenter");
returnUrl.setAuthenticationMethod("email");
// recipient information must match embedded recipient info we provided
// in step #2
returnUrl.setEmail("***#gmail.com");
returnUrl.setUserName("My Name");
returnUrl.setRecipientId("1");
returnUrl.setClientUserId("10111");
I am using production account with valid promoted integrator key and DocuSign Java API.
***#gmail.com user should get an email after signing process. But he/She is not getting any email. DocuSign server is sending all emails to the user whose credentials were used for creating envelope and Iframe URL.
If you set the clientUserId property for a recipient, you're making them an embedded recipient, and (by default) DocuSign does not send emails to embedded recipients. This behavior is by design.
UPDATE
It seems that there's an account configuration setting (i.e., that you can set via the DocuSign web UI) that will make DocuSign send the 'envelope complete' email to embedded recipients. See info in this support thread for more info: https://support.docusign.com/en/answers/00008788.
I am using amazon SES to send notification emails in my project. When a user replies back to this email I want to trigger some actions (like a ticket creation or update). Is it possible to know the contents or headers of the email for which user is replying ?
If the replying user's email system supports it (most do), you should receive an In-Reply-To: Header containing the message-id of the email you sent. If you kept that message (along with the message id) you can use this to retrieve original email.
Sometimes the Refereces: Header might be useful as well
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.
I have read all the reference in stackoverflow. However, nothing matches in our goal. How can i use bcc in sendmail method in java?
According to the RFC for SMTP, RFC 2821 (link), it is not possible to send an email message without a To: header. (You cannot send an RCPT command without it, see section 3.3.)
As Dietrich mentions, that's not possible with the RFC. If the primary goal is to send to the bcc target email addresses, you could provide a dummy to email address (such as your own email address or a reply-to email), which would fulfill that technicality while still allowing you to send the email to the desired bcc targets.
msg.addRecipient(Message.RecipientType.BCC, new InternetAddress("joe#example.com"));
By default, JavaMail collects all the recipients specified on the Message object, including Bcc recipients, and uses them in the RCPT command to the SMTP server. The Bcc recipients won't show up in the message headers, however (which is the whole point of Bcc).
How to set the Return-Path to an email address other than Sender address using JavaMail?
The code below does what you want, and does it in the correct way. Reread what you yourself posted in the comment
From: RFC2821: 4.4 Trace Information
When the delivery SMTP server makes
the "final delivery" of a message, it
inserts a return-path line at the
beginning of the mail data. This use
of return-path is required; mail
systems MUST support it. The
return-path line preserves the
information in the
from the MAIL command. Here, final
delivery means the message has left
the SMTP environment. Normally, this
would mean it had been delivered to
the destination user or an associated
mail drop, but in some cases it may be
further processed and transmitted by
another mail system.
and a few lines later.
A message-originating SMTP system
SHOULD NOT send a message that already
contains a Return-path header.
If you carefully read this you will understand that only the final smtp-server/delivery agent is supposed to add the Return-Path header. It is not something you as client (trying to send a mail) should do. The final smtp-server will base the Return-Path header on the sender address of the envelope (SMTP MAIL FROM part).
So setting mail.smtp.from is the correct way to tell java that the envelope sender address should be different from the from part.
If you have troubles understanding what the different from's are just take a look at a telnet smtp-session. Where replyto#example.com should correspond to mail.smtp.from and from#example.com to m.addFrom(...);
telnet smtp.example.com 25
220 smtp.example.com ESMTP .....
helo computername
250 smtp.example.com Hello computername [123.123.123.123]
mail from:<replyto#example.com>
250 <replyto#example.com> is syntactically correct
rcpt to:<rcpt#foo.com>
250 <rcpt#foo.com> verified
data
354 Enter message, ending with "." on a line by itself
To: Joey <to#joey.com>
From: Joey <from#example.com>
Subject: Joey
Hey Joey!
.
250 OK id=....
Quit
props.put("mail.smtp.from", "replyto#example.com");
Session session = Session.getDefaultInstance(props, null);
MimeMessage m = new MimeMessage(session);
m.addFrom(InternetAddress.parse("from#example.com"));
I've experienced the same issue and found the only solution discussed putting property "mail.smtp.from" props.put("mail.smtp.from", "replyto#example.com");
Still this solution was not suitable for me because I'm sending lot's of e-mails from different users, so recreating session for each e-mail would be horrible for prodictivity.
So I found another solution after reading JavaMail sources:
1) Use SMTPMessage(extends MimeMessage) instead of MimeMessage.
2) Use setEnvelopeFrom(String) method.
3) Use SMTPTransport to send e-mail (I didn't try with others).
Here is a code example:
SMTPMessage message = new SMTPMessage(session);
message.setEnvelopeFrom("returnpath#hotmail.com");
...
transport.sendMessage(message, message.getAllRecipients());
I found that if the 'mail.protocol' property is set to something other than 'smtp' (like 'smtps'), then only the following would work:
props.put("mail.smtps.from", "replyto#example.com");
This allowed me to avoid using the SMTPMessage class as described in GiorgosDev's answer (classes in the 'com.sun' package aren't intended to be public API).