views:

37

answers:

1

How to send mail from any mail id through java? i meant how can we set from : address in mail any that we want.

+1  A: 

Use the standard Java Mail API and just call setEnvelopeFrom() on the message.

Aaron Digulla
Why not use the `setFrom()` method?
Jesper
@Jesper, else the SMTP server and/or Spamfilters will jerk.
BalusC
MimeMessage msg = new MimeMessage(session); msg.setText(text); msg.setSubject(subject); msg.setFrom(new InternetAddress("[email protected]")); it still shows the from as the authenticated user. ref: http://code.geekinterview.com/java/send-email-using-gmail-mail-server.html
org.life.java
@abc: So? You used setFrom() instead of setEnvelopeFrom(). What did you expect?
Aaron Digulla
i expect from mail address can be any thing i want to set/.
org.life.java
Yes, it's just a string. That's why you can't trust "From" in an email and why it's so hard to fight spam.
Aaron Digulla