SMTP relay works with Thunderbird but not with Javamail

Hi all,
I'm really clueless now and decided to ask for help here in this forum.
I'm trying to send a mail via an SMTP server which needs a login.
I keep getting the error message
"javax.mail.SendFailedException: 554 <[email protected]>: Relay access denied"
I read many postings in this forum which say that the smtp server's config is responsible.
But that cannot be because I'm able to send mails via the smtp-server when I use the mail client Mozilla-Thunderbird.
Thunderbird runs on the same computer as my java mail program does.
Does anyone know how this can be?
My first guess was that it must be an authentication problem.
But the following lines work well.
Transport transport = session.getTransport("smtp");
transport.connect(host, user, pwd);Maybe I should use the other way of authentication.
But unfortunately the following code leads to an authentication failure (DEBUG SMTP RCVD: 535 Error: authentication failed).
Properties props = System.getProperties();
props.put("mail.MailTransport.protocol", "smtp");
props.put("mail.smtp.host", host);
props.put("mail.smtp.auth","true");
SmtpAuthenticator auth = new SmtpAuthenticator(user, pwd);
Session session = Session.getDefaultInstance(props, auth);          with
     private class SmtpAuthenticator extends Authenticator {
          private String user = null;
          private String pwd  = null;
          public SmtpAuthenticator(String user, String pwd) {
               this.user = user;
               this.pwd = pwd;
          protected PasswordAuthentication getPasswordAuthentication() {
               return new PasswordAuthentication(this.user, this.pwd);
     }Any hints are greatly appreciated.
Thanks in advance,
Stefan

Hi,
I think it's a good idea to share a most complete view of what I'm doing.
The smtp server the problem is all about is called h8233.serverkompetenz.net.
I successfully sent a message to myself using Thunderbird via this server.
Here's an excerpt from my Thunderbird Inbox file showing that message including all headers.
From - Wed Jul 28 10:07:16 2004
X-UIDL: b125a9357a0e8f614916a3ab1a6f9af5
X-Mozilla-Status: 0001
X-Mozilla-Status2: 00000000
Return-Path: <[email protected]>
X-Flags: 0000
Delivered-To: GMX delivery to [email protected]
Received: (qmail 2762 invoked by uid 65534); 28 Jul 2004 08:06:56 -0000
Received: from unknown (EHLO h8233.serverkompetenz.net) (81.169.187.39)
  by mx0.gmx.net (mx050) with SMTP; 28 Jul 2004 10:06:56 +0200
Received: from [192.168.0.5] (a81-14-157-170.net-htp.de [81.14.157.170])
     by h8233.serverkompetenz.net (Postfix) with ESMTP id 97D1455C035
     for <[email protected]>; Wed, 28 Jul 2004 10:08:01 +0200 (CEST)
Message-ID: <[email protected]>
Date: Wed, 28 Jul 2004 10:07:09 +0200
From: Stefan Prange <[email protected]>
User-Agent: Mozilla Thunderbird 0.7.2 (Windows/20040707)
X-Accept-Language: de-at, en-us
MIME-Version: 1.0
To: [email protected]
Subject: This is the test mail's subject.
Content-Type: text/plain; charset=us-ascii; format=flowed
Content-Transfer-Encoding: 7bit
X-GMX-Antivirus: 0 (no virus found)
X-GMX-Antispam: 0 (Sender is in whitelist: [email protected])
This is the test mail's content.And here's the java program I wrote to make JavaMail do excactly the same as Thunderbird does.
          try {
               String user = "secret";
               String pwd = "secret";
               String host = "h8233.serverkompetenz.net";
               //Prepare session
               Properties props = System.getProperties();
               props.put("mail.MailTransport.protocol", "smtp");
               props.put("mail.smtp.host", host);
               props.put("mail.smtp.user", user);
               Session session = Session.getDefaultInstance(props, null);
               session.setDebug(true);
               //Prepare message
               Address from = new InternetAddress("[email protected]", "Stefan Prange");
               Address to = new InternetAddress("[email protected]");
               MimeMessage message = new MimeMessage(session);
               message.setFrom(from);
               message.setReplyTo(new Address[]{from});
               message.setRecipient(Message.RecipientType.TO, to);
               message.setSentDate(new Date());
               message.setSubject("This is the test mail's subject.");
               message.setText("This is the test mail's content.");
               message.saveChanges();
               //Send message
               Transport transport = session.getTransport("smtp");
               transport.connect(host, user, pwd);
               if (transport.isConnected()) {
                    System.out.println("SUCCESSFULLY CONNECTED to SMTP SERVER");
                    System.out.println();
               } else {
                    System.out.println("FAILED TO CONNECT to SMTP SERVER");
                    return;
               transport.sendMessage(message, message.getAllRecipients());
               transport.close();
          } catch (UnsupportedEncodingException e) {
               e.printStackTrace();
               return;
          } catch (NoSuchProviderException e) {
               e.printStackTrace();
               return;
          } catch (MessagingException e) {
               e.printStackTrace();
               return;
     }As you already know the java program fails.
Here's its console output.
DEBUG: getProvider() returning javax.mail.Provider[TRANSPORT,smtp,com.sun.mail.smtp.SMTPTransport,Sun Microsystems, Inc]
DEBUG SMTP: useEhlo true, useAuth false
DEBUG: SMTPTransport trying to connect to host "h8233.serverkompetenz.net", port 25
DEBUG SMTP RCVD: 220 h8233.serverkompetenz.net ESMTP Postfix
DEBUG: SMTPTransport connected to host "h8233.serverkompetenz.net", port: 25
DEBUG SMTP SENT: EHLO spnotebook
DEBUG SMTP RCVD: 250-h8233.serverkompetenz.net
250-PIPELINING
250-SIZE 10240000
250-VRFY
250-ETRN
250-AUTH PLAIN LOGIN
250-AUTH=PLAIN LOGIN
250 8BITMIME
DEBUG SMTP Found extension "PIPELINING", arg ""
DEBUG SMTP Found extension "SIZE", arg "10240000"
DEBUG SMTP Found extension "VRFY", arg ""
DEBUG SMTP Found extension "ETRN", arg ""
DEBUG SMTP Found extension "AUTH", arg "PLAIN LOGIN"
DEBUG SMTP Found extension "AUTH=PLAIN", arg "LOGIN"
DEBUG SMTP Found extension "8BITMIME", arg ""
DEBUG SMTP SENT: NOOP
DEBUG SMTP RCVD: 250 Ok
SUCCESSFULLY CONNECTED to SMTP SERVER
DEBUG SMTP: use8bit false
DEBUG SMTP SENT: MAIL FROM:<[email protected]>
DEBUG SMTP RCVD: 250 Ok
DEBUG SMTP SENT: RCPT TO:<[email protected]>
DEBUG SMTP RCVD: 554 <[email protected]>: Relay access denied
Invalid Addresses
  [email protected]
DEBUG SMTPTransport: Sending failed because of invalid destination addresses
DEBUG SMTP SENT: RSET
DEBUG SMTP RCVD: 250 Ok
javax.mail.SendFailedException: Invalid Addresses;
  nested exception is:
     javax.mail.SendFailedException: 554 <[email protected]>: Relay access denied
     at com.sun.mail.smtp.SMTPTransport.rcptTo(SMTPTransport.java:804)
     at com.sun.mail.smtp.SMTPTransport.sendMessage(SMTPTransport.java:320)
     at de.zorro.util.test.MailTest.main(MailTest.java:62)I hope I gave a sufficient picture of my problem.
Does anybody know what's wrong in my java program?
Stefan

Similar Messages

  • Imap smtp settings work in thunderbird but not in mail

    Hello. One of my imap accounts can't send mail from apple's mail anymore (since updating to 10.8). The exact same settings (Server, Port, Security, Authentification, User Name) on the same computer work in thunderbird. Any idea?
    Thanks

    Who is your ISP? Have you checked to see whether the form of Username required is only the Username in front of the @ in your email address, or the entire email address needs to be entered as the Username. Mail is very explicit, and never guesses which form is needed.
    Are you now using 10.6 -- your system info needs updating if so.
    Ernie

  • HT3387 When I use pages the languages that I mainly use are English and Hebrew. The spellchecker works for English but not with Hebrew. How can I add another language to the spellcheck?

    When I use pages the languages that I mainly use are English and Hebrew. The spellchecker works for English but not with Hebrew. How can I add another language to the spellcheck?

    http://m10lmac.blogspot.com/2011/06/extra-spell-checking-dictionaries-for.html

  • Direct URL Working In IE but not with New Domain

    Hey Guys
    Something very weird here.
    This music player for www.arikecansing.com works in Mozilla
    but not IE. The site is being hosted here
    www.tahnaiya.com/clients/arike and that link works in IE but not
    under the other domain www.arikecansing.com Weird huh? Does anyone
    know why this is?
    The playlist.xml file is this but do note that i did change
    the mp3 name so the mp3 cannot be downloaded. This site is for my
    client. I would extremely appreciate any help
    <?xml version="1.0" encoding="utf-8" ?>
    <mp3s>
    <file name="song 1" file="
    http://www.tahnaiya.com/clients/arike/music/everything.mp3"
    />
    </mp3s>
    I did try changing the file to this but it still didn't work
    <?xml version="1.0" encoding="utf-8" ?>
    <mp3s>
    <file name="song 1" file="
    http://www.arikecansing.com/music/everything.mp3"
    />
    </mp3s>

    I am not sure...but have you heard that NS 6/Mozilla are use based on standards. So they dod not support some of the proprietary JS/CSS/Misc functionality of IE or NS 4.0+ versions. You can read more about the JavaScript differences on Netscape's NS6 evangism site. Maybe you are missing something. I think I remember reading something about getElementByID/Name ...

  • SMTP relay works for external recipient but not for internal recipient

    Relay allowing external recipients but not internal recipients. Running Exchange 2010.

    Whats the error you gotten for the NDR
    Blog: http://theinfraguys.com
    Follow me at Facebook
    The Infra Guys Facebook Page
    Please remember to click Mark as Answer on the answer if it helps you in anyway

  • Want to delete mails from Thunderbird but not from the server?

    Hi,
    Please tell me how to configure the settings of Thunderbird so that if i delete any mail from Thunderbird that mail would be delete only from Thunderbird not from server. I'm using IMAP configuration for all my mail accounts and I'm using Thunderbird in my laptop and tablet both.
    Currently i'm using Thunderbird 24.4.0 and i just want to delete my useless mails from Thunderbird but not from the server without using pop-3 settings.
    Actually the reason for this Question arises because whenever i use to uninstall and reinstatement Thunderbird, i use to take "profiles" as a back up and its size is increasing day by day that is making a big issue to me as i cant take a back up of such a big size file.

    Imap mail accounts keep the emails on the server and you see a remote view of those emails and folders.
    When you subscribe to see a folder, the headers are downloaded, when you select an email to read, the entire folder is downloaded to a temp cache facilitating quicker access. If you synchronize folders, then a copy of that folder is downloaded to an mbox file in your profile, so that you have a copy of the server folder. When you make any changes to a synchronized folder, read an email, delete or move etc, then Thunderbird will resynchronize with the server to update the server. A synchronized folder allows you to work in 'offline' mode and this is the best time to perform a backup as you know there is a temporary stop on synchronizing as you are offline. They will resynchronize when you go back into 'online' mode.
    So, with IMAP mail accounts, the folders you see in Thunderbird are the same folders on the webmail server. If you make any changes via Thunderbird or webmail then you are changing the same folder. You cannot delete an email without deleting it from the server, they are one and the same.
    What you can do is move/copy an email into Local Folders and delete the one on the server. The Local Folders emails are kept in your Profile on your computer, these folders/emails are not on the server, unless you chose to keep a copy of them on the server.
    Pop mail accounts cannot see the folders on the server. They only access the server Inbox folder and download emails not previously downloaded to the mail account Inbox in Thunderbird. These emails are kept on your computer in your profile folder. You can select to keep a copy on the server or not. You can choose to delete emails off your computer and off the server or not.
    If the mail account is gmail , have you subscribed or even synchronized to see the 'All Mail' folder ? Gmail's all Mail folder is their Archive folder, it keeps a copy of all of your non-deleted emails. So, you do not need to subscribe to see this folder as it only shows you what you can already see in other folders. It doubles the disc space.
    Please read section on 'All Mail' at this link.
    * http://kb.mozillazine.org/Using_Gmail_with_Thunderbird_and_Mozilla_Suite
    You do not have to download/synchronize the entire folder. You could select to only synchronize the most recent xx days of emails.
    see info here:
    * https://support.mozilla.org/en-US/kb/imap-synchronization#w_configuring-synchronization-and-disk-space-usage

  • Wifi works at home but not when away from home

    My Wifi works at home but not when away from home, what is wrong?  I thought with a phone plan I didn't need to have a wifi connection.

    You either need WiFi or Cellular (or both). If you have neither, you can't connect to the internet.
    Most people use WiFi at home and Cellular while away from home, or connect to public WiFi networks where there are some.

  • How to send active links in email from firefox. Works in IE but not Firefox... Is there a setting to change?

    how to send active links in email from firefox. Works in IE but not Firefox... Is there a setting to change?
    == This happened ==
    Every time Firefox opened
    == Always

    Check with your web mail service provider for help with that issue.

  • Medical app from Intuit works in IE, but not Firefox.

    Encrypted medical app works in new IE, but not Firefox. Everything works down to the end, and click on "continue" and nothing happens. A tech and I have spent hours on this. Did not work on FF5 or 6. Did not work on old IE, but did on fresh new version with no data files copied in.

    If it works in IE but not FF, then it has nothing to do with the mp3s. More likely it's because of the HTML on the page.
    To start, page is missing DOCTYPE declaration... a MAJOR problem. The DOCTYPE declares which set of rules the browser will use to display the page. Without it, different browsers go crazy or do not work at all.
    http://www.w3schools.com/tags/tag_DOCTYPE.asp
    Validate the html code here:
    http://validator.w3.org/
    You will have to fix all the errors if you want this to work in all browsers.
    Best wishes,
    Adninjastrator

  • Spry menubar works in IE, but not Firefox

    I added a very simple Spry horizontal menubar to the top of all pages in my web (I'm using DWCS4 and Spry 1.6). When I preview it in Firefox locally, it seems to work, but when it is uploaded to the web server it works in IE, but not in Firefox. Instead of a menubar, I see a stack of bulleted hyperlinks. In IE, it displays properly.
    Website is http://www.stevegoldman.com.
    How can I fix this problem so that it works with all browsers properly?
    -- Martin

    I just tested your site with firefox (latest version) and it works just fine. I also tested it in IE: 7.0 and it worked fine for that too. Looks like you have either fixed the problem or you have a different version of firefox than me or something.
    Favorite qoute: "do unto other as you would do unto yourself"
    Favorite hobby: airsoft / electric aeg airsoft guns
    Airsoft Sniper Rifles

  • Works in IE but not FireFox?

    site is here
    http://carolyoungs.myartsonline.com/
    when i hosted it on a different server it worked in both browsers, now i changed to a different free host because of the mp3 file i have with the site, and some sites will not host mp3 and it only works with IE
    can anyone help me out?

    If it works in IE but not FF, then it has nothing to do with the mp3s. More likely it's because of the HTML on the page.
    To start, page is missing DOCTYPE declaration... a MAJOR problem. The DOCTYPE declares which set of rules the browser will use to display the page. Without it, different browsers go crazy or do not work at all.
    http://www.w3schools.com/tags/tag_DOCTYPE.asp
    Validate the html code here:
    http://validator.w3.org/
    You will have to fix all the errors if you want this to work in all browsers.
    Best wishes,
    Adninjastrator

  • Spry form validation working in IE but not in Firefox or...

    Ok putting together a contact us form and would like a few
    fields to be required. It works in IE7 but not in Firefox, Safari
    or Google Chrome. In IE7 I get the error msg for no valid email but
    in the other browsers it just does nothing. Here is the link to the
    page
    Aspen
    Homes
    Can anyone help with this? I have used Spry on a couple other
    site and never had an issue. I am updated to the most recent
    version also. I am running
    Vista Ultimate (64-bit)
    DW CS3 or DW CS4 (both do the same thing)
    I have attached my code here in a txt file
    Page
    Code
    thanks
    B

    Anyone?

  • Sockets work on localhost but not remotely?

    hi there,
    I have created a simple multithreaded client / server program.
    The Server listens on port 2222 for clients. When a client connects - the client sends its ip address to the server and then disconects. More than 1 client can connect at the same time to the server and the server also listens continuasly. I have 2 problems with the program...
    a) the programs work on localhost but not on remote machines? (Well not over my LAN anyway).
    b) I am getting 2 lots of 'datain' when the server recieves an ip address from the client when the client should only send it once.
    The code is below - any help would be greatly appreciated.
    //TCPServer.java
    import java.io.*;
    import java.net.*;
    class TCPServer {
         public static void main (String args[]) throws IOException {
              ServerSocket serverSocket = null;
              boolean listening = true;
              try {
                   serverSocket = new ServerSocket(2222);
              } catch (IOException e) {
                   System.err.println("Could not listen on port: 2222");
                   System.exit(-1);
              System.out.println("Server Started...\n");
              while (listening)
              new TCPServerThread(serverSocket.accept()).start();
              serverSocket.close();
    //TCPServerThread.java
    import java.net.*;
    import java.io.*;
    public class TCPServerThread extends Thread {
        public Socket socket;
        public TCPServerThread(Socket socket) {
         super("TCPServerThread");
         this.socket = socket;
        public void run() {
                   try {
                   BufferedReader datain = new BufferedReader (new InputStreamReader
                        (socket.getInputStream()));
                        System.out.println("ip address recieved");
                        System.out.println (datain.readLine () + "\n");
                   } catch (IOException e) {
                        System.err.println("Cannot read in ip address\n");
                        e.printStackTrace(); // show the error
                        System.exit(-1);
         } //TCPClient.java
    import java.io.*;
    import java.net.*;
    class TCPClient {
         public static void main (String args[]) throws Exception
              String hostname;
              int portNumber;
              String portString;
              BufferedReader inFromUser =
                   new BufferedReader (new InputStreamReader(System.in));
                   System.out.println("What host would you like to connect to?");
                   hostname = inFromUser.readLine();
                   System.out.println("What port would you like to connect to?");
                   portString = inFromUser.readLine();
                   portNumber = Integer.parseInt(portString);
                   System.out.println("Connecting to port " + portNumber + " of " + hostname + "....\n");
                        Socket clientSocket = new Socket(hostname, portNumber);
                        Socket sock = new Socket (InetAddress.getLocalHost(), portNumber);
                        BufferedWriter dataout;
                        java.net.InetAddress i = java.net.InetAddress.getLocalHost();
                        System.out.println("Sending ip address...\n" + i.getHostAddress());
                             dataout = new BufferedWriter (new OutputStreamWriter (sock.getOutputStream()));
                                  dataout.write (i.getHostAddress());
                                  dataout.flush();
                                  sock.close();
                                       clientSocket.close();
                             }Oh, yeah - check out my site below, I am trying to write an audio streaming client / server in Java if anyone is interested in getting involved or just being nosey....
    http://www.projectg.dsl.pipex.com

    In your client you are creating two sockets (why?). One connected to localhost, the other connected to the host specified using readLine.
    If your client runs on the same machine you have started your server, you have two connects to your server instead of one.
    The ip adresse is sent using the socket connected to localhost. That is why it does not work on remote machines.
    Hope this helps.
    J&ouml;rg

  • QTSS Works on Mac but not the other

    I have a Server running OS X Server 10.5.8. I am running QTSS and Apache on this machine, however I am having issues with Quicktime streaming. One mac here is able to successfully stream but all other macs on our network fail to connect despite the QTSS "Connections" window shows the connection to the machine trying to stream the video. In the end on the client Quicktime X shows "Not Found" however I am able to connect to the server via other services (ARD, AFP, HTTP). I can post any logs that might help.
    Thanks in advance

    I couldn't remember what the Display Preferences had said when we tried this last spring and again in the summer, so tonight we connected it again, and wouldn't you know - it worked just fine. We didn't do anything different, so I have no clue as to why it worked this time but not before. He's thinking about getting his own big display, but didn't want to waste his money if he couldn't get it to work, so now I guess we're shopping for another 23" display - probably a used one. Thanks!

  • Link works on mac but not on pc

    Hi -
    I am trying to insert a jpg into a dreamweaver file.
    I then upload the html file along with the jpg to my server in a folder called "layout"
    So the url is:  http://www.mysite.com/layout/test.html
    The link works on mac, but not on pc's.
    Any idea why?
    Some links work on pc's like this, and others don't.
    Thanks- It's driving me crazy!!

    The link is not correct....you have it listed as" mysite.com", which I assume is where you are to insert the name of your url.
    Gary

Maybe you are looking for

  • Creative and compatibil

    Hellow, I got vista 64 bit and an old 20g Zen Touch. As it turns out thats just another way of saying "fek i'm skrewd". When I followed this neat guide [url="http://www.ehow.com/how_23074_zen-touch-work-windows-vista.html">here[/url] It appears Creat

  • Downloading apps on Mac OS X 10.8.4 with Creative Cloud App Causes Destructive Feedback on Firewall

    Okay, here's the network profile, workstation profile, and symptoms of the problem. Site Profile Network Asymmetrical 22 Mbit inbound / 2 Mbit outbound DSL terminated by a RFC 1483 Bridge into a pfSense 2.0.3-RELEASE (amd64) Firewall Hardware profile

  • AppleWorks going crazy and so am I!

    I have little or no idea about the in's and out's of computers so when I checked for prior posts that had to do with my problem I found myself very confused. I am hoping someone will have pity on me and help me out...please? I have AppleWorks 6 and a

  • Error in Queue Status

    Hi Experts, I am Doing IDoc to File Scenario. If i send an idocs sometimes file is get created in target directory and sometime it is not. i checked in SXMB_MONI, for failed messages in Q.Status column a "stop" symbol with red colour is displaying .

  • Ideas for dashboards

    hi can anyone give me ideas for a decent management dashboard for VC.our management has suddenly become fast track and wants everything fast. so help will be appreciated. regards, Olaf