net.mail.send

Dec 19, 2007 at 10:54am

net.mail.send

I’m having trouble with net.mail.send. Trying to send email from/to
my .mac account I’m getting this error message:

com.sun.mail.smtp.SMTPSendFailedException: 556 5.1.0 Invalid From
header.
at com.sun.mail.smtp.SMTPTransport.issueSendCommand
(SMTPTransport.java:1515)
at com.sun.mail.smtp.SMTPTransport.finishData(SMTPTransport.java:1321)
at com.sun.mail.smtp.SMTPTransport.sendMessage(SMTPTransport.java:637)
at javax.mail.Transport.send0(Transport.java:189)
at javax.mail.Transport.send(Transport.java:118)
at net.mail.send.deliver(send.java:71)
exception: MessagingException

I have no idea why georghajdu@mac.com is generating this message.
Also, I noticed that authentication wasn’t implemented. Is this on
the author’s to-do list? This would be nice!

I’m using JavaMail 1.4.1 and jaf 1.1.1 on a MacBook with 10.4.11 and
the latest Java release installed.

Georg

#35060
Dec 19, 2007 at 2:27pm

Hi Georg,

It’s quite possible that the error is a consequence of not
authenticating, if that’s what the SMTP server expects (the status of
response codes > 554 is sufficiently murky to not be clear with a quick
google, it seems).

Looking at the code for net.mail.send, hacking it to add authentication
shouldn’t be massively difficult – there are broadly two ways, see:

< http://java.sun.com/products/javamail/javadocs/com/sun/mail/smtp/package-summary.html>

> To use SMTP authentication you’ll need to set the mail.smtp.auth
> property (see below) and provide the SMTP Transport with a username
> and password when connecting to the SMTP server. You can do this
> using one of the following approaches:
>
> * Provide an Authenticator object when creating your mail Session and
> provide the username and password information during the
> Authenticator callback.
>
> Note that the mail.smtp.user property can be set to provide a default
> username for the callback, but the password will still need to be
> supplied explicitly.
>
> This approach allows you to use the static Transport send method to
> send messages.
>
> * Call the Transport connect method explicitly with username and
> password arguments.
>
> This approach requires you to explicitly manage a Transport object
> and use the Transport sendMessage method to send the message. The
> transport.java demo program demonstrates how to manage a Transport
> object. The following is roughly equivalent to the static Transport
> send method, but supplies the needed username and password:
>
> Transport tr = session.getTransport(“smtp”);
> tr.connect(smtphost, username, password);
> msg.saveChanges(); // don’t forget this
> tr.sendMessage(msg, msg.getAllRecipients());
> tr.close();

hth,
Owen

Georg Hajdu wrote:
> I’m having trouble with net.mail.send. Trying to send email from/to
> my .mac account I’m getting this error message:
>
> com.sun.mail.smtp.SMTPSendFailedException: 556 5.1.0 Invalid From
> header. at
> com.sun.mail.smtp.SMTPTransport.issueSendCommand(SMTPTransport.java:1515)
> at
> com.sun.mail.smtp.SMTPTransport.finishData(SMTPTransport.java:1321)
> at
> com.sun.mail.smtp.SMTPTransport.sendMessage(SMTPTransport.java:637)
> at javax.mail.Transport.send0(Transport.java:189) at
> javax.mail.Transport.send(Transport.java:118) at
> net.mail.send.deliver(send.java:71) exception: MessagingException
>
> I have no idea why
georghajdu@mac.com is generating this message.
> Also, I noticed that authentication wasn’t implemented. Is this on
> the author’s to-do list? This would be nice!
>
> I’m using JavaMail 1.4.1 and jaf 1.1.1 on a MacBook with 10.4.11 and
> the latest Java release installed.
>
> Georg
>
>
>

#119085

You must be logged in to reply to this topic.