I am using JavaMail to send automated emails from my java code. Following is the code I use to set the 'from' and 'to' attribute.
message.setFrom(new InternetAddress("XYZ#company.com", "XYZ's alias"));
message.addRecipients(Message.RecipientType.TO, receiverArray);
where receiverArray is of type InternetAddress[] and contains all the recipients email addresses.
Everything works fine with the functionality and the receiver is receiving the mail but when we open the mail in MS Outlook 2007, the sender is shown as XYZ's alias[XYZ#company.com] and to is shown as the receiver's alias only, may be taken from company's Active Directory on which one can double-click and check the properties.
I need the same to be done for the sender also, i.e. only the alias is shown and not the actual email id.
Maybe some sort of mapping has to be done between the email id I mention in from clause and the active directory.
Both the to and from have registered aliases with the company's Active Directory.
Kindly help.
Thanks in advance.
instead of adding the recipient using a string, try an InternetAddress object. This will give you addresses in RFC 2047 encoding
http://javamail.kenai.com/nonav/javadocs/javax/mail/Message.html#addRecipients(javax.mail.Message.RecipientType, javax.mail.Address[])
Related
I sent a mail from my smtp server to gmail.
The message-id that I got is:
Message-ID: SMTPIN_ADDED_BROKEN#mx.google.com>
X-Google-Original-Message-ID:
Gmail appended extra parts in Message-id.
All I got on google that it can be an authentication issue.But source of mail shows:
SPF:PASS
But DKIM is not present in the source.
Do we require DKIM to be necessarily present in the mail's source??
What can I do to prevent header from being modified?
the msesage ID will be modified only if it does not obey RFC standard. so send mail with correct message id format
After many tries, I finally figured out that you need to add brackets enclosing the Message-Id
<yourid#domain.com>
I making one application that can send different email, but the email address depends of the user. I'm using mailjet to do this, after reading the doc, it's seem that i have to add every email for have the right to send email from this address, but this address are not generate by me (they are gmail, toto, etc)
I already use the Java API of mailjet to add user, and this part is working fine
But my problem is when the validation email arrive, and the person follow the link, mailjet ask to login, but he do not know what to do, because normally is my own account, i only what to add their email address to have the right to send email with them.
So the question, is how i can add email address (from gmail, yahoo...) and activate the user, without the login part.
Thanks for having choosen Mailjet to power your email!
I believe the right setup for you would be to use the Sender header. It will allow you to send email from a unique (or multiple, depending of your setup) pre-validated sender email addresses while setting the From email header to the email you want to send the email from.
In your recipients Inbox, it will display as foobar#gmail.com via notifications#mycompany.com, indicating clearly to the recipient that you're sending on behalf of foobar#gmail.com. This way, you won't be forced to validate each email address, just ones you'll
This is a very common setup for resellers and platforms sending a lot of personalised email.
In order to achieve this, please contact our [support team](https://app.mailjet.com/support] with a reference to our discussion here so they know what we're talking about. They'll guide you to the implementation it.
Hope it helps,
Best.
I have a very special requirement
I am using Java Mail API to access a user's Inbox. You can say its like a service inbox for complaints. User registers a complaint by sending an email to this address. I fetch every email from Inbox and create a new complaint. My problem is that I don't want to create unnecessary complaints for reply or forwarded emails. Is there a way to find out that.
Most email clients add Re: or Fwd: to the subject line, but I wouldn't rely on that to determine whether an email is a reply or forwarded text; for example, a German mailclient might put Betr.: in front of the original subject.
Instead, you might want to look at the In-Reply-To: header and/or the References: header. See RFC 4021 for detailed information on those headers.
You can retrieve the headers from a Message by calling the getHeader(java.lang.String) method.
Reading the email header might help, see http://javamail.kenai.com/nonav/javadocs/javax/mail/Part.html#getAllHeaders(). In case of replies, the message header would include:
In-Reply-To: Message-ID of the message that this is a reply to
In case of a forwarded message, selected headers might be preserved. Not as straight-forward as the previous case, but it might still be possible to determine if it was a forwarded message. Refer to http://en.wikipedia.org/wiki/Email_forwarding#Manual_client-based_forwarding for details.
I have an online form that allows users to email a complaint to the company. To test it I have used gmail smtp as my host. I have no problem receiving the message to the designated email account when the sender is also a gmail but I want the "From" to not be limited to just gmail accounts. It appears that smtp is only good for sending emails from the same server?
Example: My form works great if the from is abc#gmail.com and the company email is company#gmail.com.
However if xyz#yahoo.com is entered for the sender, the receiver company#gmail.com never gets it.
Any help would be greatly appreciated. I can provide my code as well if that is needed.
Your problem is a common security restriction when using SMTP. Outgoing SMTP email can only contain a "mail from" address belonging to the sender. If you break this rule, your email may be considered SPAM.
The following will allow your recipient to reply to an alternate address.
Properties properties = new Properties();
props.put("mail.smtp.from", "abc#gmail.com");
Session session = Session.getDefaultInstance(props, null);
MimeMessage m = new MimeMessage(session);
m.addFrom(InternetAddress.parse("xyz#yahoo.com"));
m.setReplyTo(InternetAddress.parse("xyz#yahoo.com"));
See also
http://www.mkyong.com/java/javamail-api-sending-email-via-gmail-smtp-example/
http://www.openspf.org/Best_Practices/Webgenerated
Well you will have to own the other email as well as set it to work with gmail,
Check here for more details.
It's probably better to send the message to your company's mail server using the identity of the user who owns the application on the server, and include the information that the customer provides in the online form as data in the message you send. The message won't look like it came from the customer, but then it really didn't come from the customer since it wasn't sent using the customer's mail server.
I am using document.getItemValueString("INetSendTo") to get the mail address of recipient exact mail address. But some of the mail document I am getting null value. In any other field the email address will be stored?
Email addresses are always stored in the From, SendTo, CopyTo, BlindCopyTo fields.
With certain configurations of the server the corresponding internet email adresses for internal addresses are stored in the INetFrom, INetSendTo, INetCopyTo and INetBlindCopyTo fields.
Actually, you cannot rely on the address fields. According to the SMTP RFCs, messages are to be delivered to the recipients listed in the RCPT TO command string as specified in RFC821, even if all of the headers (To, Cc, Bcc) in the RFC822 messsage are missing or empty. There is a configuration option for Domino to create a BlindCopyTo item for any RCPT TO recipient who was not listed in any of the RFC822 headers, but you cannot assume that this option was enabled at the time the message was received.