Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

how to create a null sender using javamail?  RSS feed

 
Randy Diffenderfer
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I want the MAIL SMTP command to reflect a NULL sender:

MAIL From:<>

How can I do this? As close as I've gotten is setting mail.smtp.from prop to "<sp>", where <sp> is a single space. However, this is reflected in the transaction as:

MAIL From:< > (yes, there is a single space in there :-) )

Googling/Fora Searching has drawn blanks...

Hoping someone knows this little trick!
 
Paul Clapham
Sheriff
Posts: 22185
38
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My guess is, if your code works with a string of length one containing a space but not with a string of length zero, then perhaps that isn't permitted by the RFCs which define how e-mail works. (I assume you already tried the zero-length string.)
 
Randy Diffenderfer
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This really has nothing to do with RFCs, in that the "null sender" is routinely used to indicate a bounced message.

It's all about the javamail code itself, and its (unknown to me) way to specify an "empty string" as the argument for the "MAIL From" SMTP command.

Yes, the code does seem to accept the property string of one space. When the empty string is used, the "default" identity becomes the "MAIL From" argument, as in "user@boxname", which is definitely not what I am looking for. I have to think there is some way to do this, as it seems that it's possible to fashion a mail relay out of the javamail set of classes, and there is a need to "bounce" messages in that type of operation.

 
Paul Clapham
Sheriff
Posts: 22185
38
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As you might have guessed that's mostly beyond what I know about e-mail. However the release notes for a recent version of JavaMail say:
This release of JavaMail includes EXPERIMENTAL support for creating
and parsing Delivery Status Notifications, as defined by RFC 3462
and RFC 3464. To make use of this support you need to include dsn.jar
in your CLASSPATH along with mail.jar. See the javadocs for the
com.sun.mail.dsn package for more details.

Are you already using that, or does it look like something which might be useful to you?
 
Randy Diffenderfer
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I had looked through the documentation for the DSN classes, hoping to fathom an underlying approach, but to no avail.

This isn't quite what I'm after, as I'm not building a DSN, merely trying to send a "bounceproof" message (a bounce of a null sender message goes into the bit bucket) with "normal" content. Still, a DSN is sent out with a null sender, so the hint is that this is doable somehow.

I just don't know how. :-)
 
Randy Diffenderfer
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

OK -- am a whole lot closer to where I need to be...

It appears that SMTPMessage has a hook for setting the envelope sender, however that class is provided by com.sun.mail.smtp which apparently *is* packed into the javamail 1.4.1 bundle, but not the current 1.4.4 bundle.

WTH... Explanation as to why the change? The Oracle buyout? Martians?
 
Rob Spoor
Sheriff
Posts: 20895
81
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Are you aware that sending emails without a valid from address is likely going to result in your emails being marked as spam?
 
Randy Diffenderfer
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
MAIL From:<>

...is a perfectly valid SMTP envelope address for a message, in particular a bounced message. I'm not sure how the idea that it isn't has propagated!

Yes, I know that bounces (often relating to backscatter) are looked upon with a jaundiced eye nowadays -- I do 'mail hygiene' as my day job...

In this case, I'm just trying to create a specialized mail "ping" message from a windows based appliance like "thing".

======= back to the original question ========

ok ... i found the com.sun.mail.smtp.SMTPMessage class and used the setEnvelopeFrom( "" ) method on my message. No joy. The code refuses to honor a 0 length string as being a valid address, instead percolating up to the next level of address in the list it uses to find an envelope "From".

Sigh...
 
Randy Diffenderfer
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

End of the hunt... Browsing through the developer/maintainer forum for javamail I find this:

http://kenai.com/projects/javamail/forums/forum/topics/1696-Support-for-RFC-2821-null-return-paths-

...
But, you can use SMTPMessage.setEnvelopeFrom("<>"), or set the "mail.stmp.from" property,
to cause that address to be used in the SMTP "MAIL FROM:" command.
...

And that does what I need it to do.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!