Sending mail takes 2 seconds

When I use this code, it takes 2 seconds to execute.
It is a static method and code is run on my tomcat server.
It all works fine, just the length of time to execute.
Questions:
Why is this taking 2 seconds, any way to speed it up ?
Should I just stick it in a separate thread and let it work on it's own so users don't have the delay ?
Thanks
public static void doIt(String to, String subject, String text) {
        try {
            Context initCtx = new InitialContext();
            Context envCtx = (Context) initCtx.lookup("java:comp/env");
            Session session = (Session) envCtx.lookup("mail/Session");
            Message message = new MimeMessage(session);
            message.setFrom(new InternetAddress("[email protected]"));
            InternetAddress list[] = new InternetAddress[1];
            list[0] = new InternetAddress(to);
            message.setRecipients(Message.RecipientType.TO, list);
            message.setSubject(subject);
            message.setContent(text, "text/plain");
            Transport.send(message);          
        catch(Exception e){
    }Edited by: patftrears on Mar 30, 2010 9:32 AM

Obviously you should do some debugging to determine which statement is using most of the time.
Most likely it's the call to Transport.send, but you should prove that.
Since Transport.send is talking to your server, the delay could be entirely waiting for your server.
Also, Transport.send will need to look up the host name that you're connecting to. If your name
service is slow, that could explain it too.

Similar Messages

  • Sending mail take too long time exchange 2011 in iphone4

    when i try to sending mail take too long time.
    stay long time in outbox folder.
    i'm using exchange 2011 in iphone4 with latest updates.

    Hi,
    This is a characteristic of some, but not all, ISPs, and not the SMTP itself. It involves DNS. See:
    http://discussions.apple.com/thread.jspa?messageID=10391853&#10391853
    Ernie

  • Sending mail takes forever

    why does the iphone take an hour to send mail using the mobile me service?
    My freind's emails go out instantly on his gmail account.
    Is apple just charging top dollar for bush league service again? I thought they upgraded things a while ago so it would offer close to service that you get for FREE elsewhere. Is that not correct?
    Doug M
    Message was edited by: Douglas Meeuwsen

    I just noticed hat e-mails are taking a long time to get set out. maybe is the network?

  • Sending mail takes a while.

    Mail works fine, apart from it takes a while to send, or more to the point, there is a noticeable delay before the message is finally sent. I didn't have this quirk in 10.4 so why if Mail has been completely rebuilt from scratch in Leopard, this happens?
    any ideas anyone?

    I have something similar to this issue too.
    When I send an email the entire mail.app locks up until the email is sent... which could take up to a minute.
    Weird. It doesn't happen all the time, but most of the time when I'm emailing people outside of our organization

  • Mail will not send, Mail will not send

    Why Can't I send email from my iPad? I previously was ably to do so. First lost the ability to send from one e account and today lost the ability to send mail from a second account.

    If it was just one account, I would say to check the outgoing server settings, which you can still do, but the odds of them both going ahywire at the same time seem sort of slim. I t doesn hurt to check however.
    Settings>Mail, Contacts, Calendars>Your email account>Account>Outgoing mail server - tap the server name next to SMTP and check in the primary server and make sure your username and password are entered and correct - even if it says that the password is optional.
    You can try quitting the mail app completely and reboot the iPad as well. Sometimes that cures mysterious issues.
    Go to the home screen first by tapping the home button. Double tap the home button and the recents tray will appear with all of your recent apps displayed at the bottom. Tap and hold down on any app icon until it begins to wiggle. Tap the minus sign in the upper left corner of the app that you want to close. Tap the home button or anywhere above the task bar.
    Reboot the iPad by holding down on the sleep and home buttons at the same time for about 10-15 seconds until the Apple Logo appears - ignore the red slider if it appears on the screen - let go of the buttons. Let the iPad start up.

  • TS3276 Well it happened again. Why does my apple me account stop sending mail for no apparent reason. One minute it is working find and 10 seconds latter you get error messages that it does not recognize your password. I am really fed up with the mail sof

    Things were going well. Mail was working fine and then the following error message appears out of nowhere. I had not changed any settings. From that point on all efforts to send mail failed, and the error message appeared even thought I used the password to log back in after I quit. Now, an hour after the problem started it takes my password (on the second try after the error message appears) once and sends a test message. Then, one minute later it gives the error message again and refuses to send anything. Why is mail so inconsistent? What can I do in the future to address the problem?
    Error message reads "The SMTP server "xxxxx" rejected the password for user "xxx" Please re-enter your password or cancel.
    When mail does work again. Should I click the remember this password in keychain or am I just asking for more trouble?
    I'm writing this using my IMac computer in a different room. The error also occurs on my powerbook running my new MacBook Pro 12 inch.
    Fed up Mac user.

    I"m no expert but this used to happen to me all the time (stop downloading, asking for my password, nothing downloading, walking away- 24 hours or more later, all is fine, only to later start all over again)
    Well, i gave up for a long time and stopped using that account with mac mail and only accessed it online..recently went and changed the pop3 to only pop and now it works beautifully and seamlessly. Don't ask me why or how, but it does so thought I'd share.

  • Apple Mail takes a very long time to send messages.

    A few weeks ago, Apple Mail started to act up.
    Even small email messages without images now take 30 seconds to send.
    They sit forever in the outbox.
    What can be the reason of this?

    Window menu -> Activity menuitem will give you all the background processes of Mail, and should give you an idea what is hanging its processes.  
    Mail can especially get tied up if Spotlight or Time Machine are trying to redo their indices.

  • 60 seconds to send mail, really?

    You know, I'm really, REALLY starting to feel a little annoyed at Apple lately. Mail is the slowest application on this planet. Takes forever to load mail, even longer to send it. And no attachments either.
    I am on a cable modem, using a Mac Pro, with the latest this and that. Gmail is 1.5 billion times faster. Sigh...

    :: confused ::
    Sorry, how is this Apple's problem?
    Clearly 60 seconds to send mail isn't standard, otherwise lots of people would be complaining. Therefore it's going to be some issue with your mail client, your network connection or your mail server.
    You'd need to do some troubleshooting to work out where the problem is. For example, does it take a long time for the mail client to find the mail server? (might indicate a DNS problem), or does it take a long time to authenticate to the server? (may indicate a mail server problem), or does it connect quickly, but take a long time to transfer the email data? (may indicate a network problem).
    You might also try playing with the options for your mail server - for example toggling the authentication mechanism (if your server supports authentication), or SSL/TLS (if your server supports that).

  • HT1338 sending of mail takes more than than other mail accounts

    Got a new mac pro, and made an yahoo.account on the mail.
    When im sending mails with pictures, it takes a lot of time than usual .
    It was set ut as the apple mail usual sets up. Very easy-

    I know nothing about networks and all the techs involved. I only have a modem, airport extreme and I use at&t as a DSL provider.
    When I send an email, while sending, if I click on connection doctor it shows "connecting..." during that 30 seconds period. If I send another e-mail immediately after, it goes fast.
    What makes me believe the problem it's about Mail is that it works fine with another software (Eudora) in my Macbook, and also with a PC. I tried another Macbook with Mail and the problem persists. This is not a big issue, but it is not normal. I will try the new Snow Leopard and hope that will fix the problem.
    Thanks for your attention.

  • SquirrelMail Takes a long time to send mail

    Am running SquirrelMail 1.4.10a in Tiger Server.
    Users can login, receive mail, compose new mail, and read mail fine. My problem is when a user sends mail, it takes up to 45 secs to complete the send. The sent email will show up in the "Sent" folder okay and it is sent, however, it never closes out of the "Compose" window and seems to time out.
    Any ideas?
    Do I need to add a hosts file or edit an entry into my current hosts file?
    Thank you,
    Steve K

    Hi Steve,
    I'm having the same problem with 2 server that I'm running, web mail runs perfect but the compose window won't refresh after clicking on send!! didi you have any luck fixing this issue? i found out that for some people restarting apache would help but not for me!! maybe you should try!!

  • Switching in workspace between any item to Emails takes 45 seconds for mail to display.

    Have a blackberry Q5 on OS10.3. via BES 12.  When switching between items in workspace it takes 45 seconds to switch and siplay mail in corporate email account.  Any switching between other items is instant.
    Device has been replaced twice.
    device has been reloaded and also used OS 10.2
    User account on BES server has been created on BES 12 server.
    This only happens when you switch to look at your emails.  Other than that, the device is working.

    Hi Andy,
    The switching time depends on the client buffer state and the keyframe interval of the content.  The switch is not complete until it is visible to the user, meaning the buffer has to play through.  So if the client has buffered 15 seconds of content, it will take around 15 seconds to make the switch.  This also depends on your FMS settings since keyframes can be generated on the fly.
    This is easy to monitor if you turn on logging for the OSMF Flex project.  You'll see something like this in your log:
    Calling for switch to 4 at 1708 kbps
    Switching to index 4 at 1708 kbps
    event.info.code=NetStream.Play.Transition
    info.code=NetStream.Play.TransitionComplete
    Transition complete to index: 4 at 1708 kbps
    The "NetStream.Play.Transition" means the server has acknowledged the request and has begun the switching process.  The "NetStream.Play.TransitionComplete" is an in-stream event and this means the switch is visible to the user (the buffer has played thru and the new bitrate stream is now viewable).  The time between the "Transition" and the "TransitionComplete" will be very close to the size of the current buffer.  I don't belive we are logging the current buffer size right now, but you can easily do that in your player by getting to the netStream object via the LoadTrait (in sprint 10, sprint 9 will be the loadedContext). There is another thread here about getting to the netStream object if you want to try this yourself.
    Hope that helps,
    - charles

  • HT2500 without changing settings, iMac mail V4.6, 1)will not save password 2)takes accounts offline 3)will not except password 4)will not send mail from accounts every time.     What happen?

    without changing settings, iMac mail V4.6,  1)will not save password   2)takes accounts offline  3)will not except password   4)will not send mail from accounts every time.
        What happen?  How do I correct this?

    Hi Nuch1,
    I found an article that is contains very thorough Mail troubleshooting steps:
    OS X Mail: Troubleshooting sending and receiving email messages
    http://support.apple.com/kb/TS3276
    You can use that article to figure out what part of the email "ecosystem" is the cause of the issue, and it can also help you attempt to resolve it.
    Hope that helps,
    David

  • Opening a new mail window takes 5 seconds to appear

    When I click New Mail it takes 4 seconds to appear for this Window. This is already for many months. I have a .Mac account and three other POP accounts and a fresh other user doesn't have this problem. I might trash some prefs, but I don't want to organize my whole E-mail again. Somebody some clue what to do?

    Go to Apple Menu > System Preferences > Network > Show: Network Port Configurations. Make sure that the configuration used to connect to Internet is at the top of the list. Also, disable any communications/networking configuration enabled, but not in use. Since you don't experience the problem when logged in as another user, this probably won't solve it, but it's worth looking at anyway.
    Now, in Mail go to Mail > Preferences > Accounts > Mailbox Behaviors for your .Mac account. Do you have Store draft messages on the server enabled? If so, disable it and see whether it makes a difference.

  • Mail takes long till it starts sending

    My Mail takes a long time (ok, about one minute or so) before it starts to send an email. OTOH my iPhone 4 sends the emails instantly. So I wonder, if there's some special reason for that, like maybe a cache or so that should/could be emptied? Thanks for a hint!
    Don

    don gmt wrote:
    Thanks for the care! Actually it was not my password - I just wasn't certain at the moment as to how "Kennwort" is correctly translated into English Now I know again - G "Kennwort" = E "Password".
    Entschuldigen
    Usually I use a POP account for my email. In addition I have also a MobileMe account. The POP accounts use port 995, the me.com port 993. All the settings are exactly the same on the iMacs and on the iPhone.
    As a test i created a new user and started there from zero - same slowness in mail. Further-on, no matter if I use one of my POP accounts or the me.com for outgoing mail, no difference.
    Both 993 and 995 are incoming ports. What are you using for outgoing ports? The default setting is to try 25, 465, and 587. You may be getting some unusual failure on the first try - probably due to ISP issues. You may want to try specifying a custom port of either 465 or 587. That will bypass the failure and cause it to connect right away. This is on the outgoing port. See my post above to find out where to locate this information.

  • Mail sends message every several seconds

    I have Gmail configured for IMAP, but when I am writing a large message, Mail shows "Sending Mail" at a roughly 10-30 second interval, which I thought was Mail saving drafts, but once I checked my online Gmail account, the email was sent, in several different parts, 29 times. Am I doing something wrong?

    karol wrote:
    I recall a somewhat similar situation when one guy texted another guy during a lecture.
    He did send the message, but the other guy's phone didn't seem to get it. It was silent. So he send it again. And again. To make it even "better", it was a two-part message ...
    For a while nothing happened and then the other guy's phone starter receiving all these messages. He had a loud, high-pitched ringtone on his phone. And he had his phone ... somewhere. Was it in his backpack? Was it in his bag? In his jacket?
    Chaos ensued.
    So you can see it could have been worse :-)
    Haha, fair enough   I was reminded of the "Look Around You" opening sequence.
    10 PRINT LOOK AROUND YOU
    20 GOTO 10
    30 RUN
    Set-up a gmail filter to delete them as they come in; that should hold me over for the time being.
    Solved.
    Last edited by apolyonn (2014-03-20 00:38:06)

Maybe you are looking for

  • Report on Process Orders

    Hi All, Kindly suggest a standard report on Vairances booked on Process Orders. Thanks & regards, Chandrakant

  • How to retrieve 5th highest salary in a single statement

    Hi, How can we retrieve 5th highest salary in a single statement

  • Javascript issue for fragment in jspx page cannot find regionId

    I am using Jdev 11.1.1.4.0 When i am calling the javascript function its not able to find the region thus my component is not found in the jsff page. Please help !!! Below is my jspx page :- <f:view>     <af:document id="d1" title="Home Page" partial

  • Switch Executive Error

    Dear All, I get the following error when trying to create a new Switch Exec Virtual device. I also get similair errors reported when trying to use current virtual devices that have been working for some time with no issues. Can anyone shed any light

  • ...Connection to DB Failing

    Hi all. We have oracle 9i release 2 databse installed and acced by clients using Forms 6i. Due to some reasons we are shifting to Oracle 10g rel 1 and PHP as front end. The new server machine has windows 2000 professional with service pack 4. i insta