How to bypass proxy when trying to send a mail using javamail smtp

Hi,
I am trying to make a servlet send a mail using javamail smtp protocol on port 25 but i m not able to send getting an exception, i suspect proxy is blocking, so any idea anyone how bypass a proxy.

And if it does turn out that there's a proxy server blocking access to your target SMTP server, the best way to deal with that is to discuss the issue with the person responsible for your network configuration.

Similar Messages

  • Trying to send e-mail using JavaMail, JBoss 5, and JNDI

    Hello there,
    Am using JBoss 5.1.0GA and JDK 1.5.0_19 on OS X Leopard.
    Created a working SendMailServlet.
    Have now decided to refactor it into two separate classes (extract out JavaMail code to a separate class and create a ServletController).
    Am also trying to use JNDI to access the connection properties in the mail-service.xml configuration file residing in JBoss.
    The Mailer class contains the reusable functionality needed to send an e-mail:
    public class Mailer {
         private Session mailSession;
         protected void sendMsg(String email, String subject, String body)
         throws MessagingException, NamingException {
              Properties props = new Properties();
              InitialContext ictx = new InitialContext(props);
              Session mailSession = (Session) ictx.lookup("java:/Mail");
    //          Session mailSessoin = Session.getDefaultInstance(props);
              String username = (String) props.get("mail.smtps.user");
              String password = (String) props.get("mail.smtps.password");
              MimeMessage message = new MimeMessage(mailSession);
              message.setSubject(subject);
              message.setRecipients(javax.mail.Message.RecipientType.TO,
                        javax.mail.internet.InternetAddress.parse(email, false));
              message.setText(body);
              message.saveChanges();
              Transport transport = mailSession.getTransport("smtps");
              try {
                   transport.connect(username, password);
                   transport.sendMessage(message, message.getAllRecipients());
                   Logger.getLogger(this.getClass()).warn("Message sent");
              finally {
                   transport.close();
    }The MailController class serves as a standard Java Servlet which invokes the Mailer.class's sendMsg() method:
    public class MailController extends HttpServlet {
         /** static final HTML setting for content type */
         private static final String HTML = "text/html";
         myapp/** static final HTML setting for content type */
         private static final String PLAIN = "text/plain";
         public void doGet(HttpServletRequest request, HttpServletResponse response)
         throws ServletException, IOException {
              doPost(request, response);
         public void doPost(HttpServletRequest request, HttpServletResponse response)
         throws ServletException, IOException {
              response.setContentType(PLAIN);
              PrintWriter out = response.getWriter();
              String mailToken = TokenUtil.getEncryptedKey();
              String body = "Hello there, " + "\n\n"
                        + "Wanna play a game of golf?" + "\n\n"
                     + "Please confirm: https://localhost:8443/myapp/confirm?token="
                     + mailToken + "\n\n" + "-Golf USA";
              Mailer mailer = new Mailer();
              try {
                   mailer.sendMsg("[email protected]", "Golf Invitation!", body);
                   out.println("Message Sent");
              catch (MessagingException e) {
                   e.printStackTrace();
              catch (NamingException e) {
                   e.printStackTrace();
    }Have the mail configuration set under $JBOSS_HOME/server/default/deploy/mail-service.xml:
    <server>
      <mbean code="org.jboss.mail.MailService" name="jboss:service=Mail">
        <attribute name="JNDIName">java:/Mail</attribute>
        <attribute name="User">user</attribute>
        <attribute name="Password">password</attribute>
        <attribute name="Configuration">
          <configuration>
            <property name="mail.store.protocol" value="pop3"/>
            <property name="mail.transport.protocol" value="smtp"/>
            <property name="mail.user" value="user"/>
            <property name="mail.pop3.host" value="pop3.gmail.com"/>
            <property name="mail.smtp.host" value="smtp.gmail.com"/>
            <property name="mail.smtp.port" value="25"/>
            <property name="mail.from" value="[email protected]"/>
            <property name="mail.debug" value="true"/>
          </configuration>
        </attribute>
        <depends>jboss:service=Naming</depends>
      </mbean>
    </server>web.xml (Deployment Descriptor):
    <servlet>
        <servlet-name>MailController</servlet-name>
        <servlet-class>com.myapp.MailController</servlet-class>
    </servlet>
    <servlet-mapping>
        <servlet-name>MailController</servlet-name>
        <url-pattern>/sendmail</url-pattern>
    </servlet-mapping>This is what is outputted when I start JBOSS and click point my browser to:
    https://localhost:8443/myapp/sendmail
    [MailService] Mail Service bound to java:/Mail
    [STDOUT] DEBUG: JavaMail version 1.4ea
    [STDOUT] DEBUG: java.io.FileNotFoundException:
    /System/Library/Frameworks/JavaVM.framework/Versions/1.5.0/Home/lib/javamail.providers
    (No such file or directory)
    [STDOUT] DEBUG: !anyLoaded
    [STDOUT] DEBUG: not loading resource: /META-INF/javamail.providers
    [STDOUT] DEBUG: successfully loaded resource: /META-INF/javamail.default.providers
    [STDOUT] DEBUG: getProvider() returning
    javax.mail.Provider[TRANSPORT,smtps,com.sun.mail.smtp.SMTPSSLTransport,Sun Microsystems, Inc]
    [STDOUT] DEBUG SMTP: useEhlo true, useAuth false
    [STDOUT] DEBUG SMTP: trying to connect to host "localhost", port 465, isSSL true
    [STDERR] javax.mail.MessagingException: Could not connect to SMTP host: localhost, port: 465;
      nested exception is:
         java.net.ConnectException: Connection refused
    [STDERR]      at com.sun.mail.smtp.SMTPTransport.openServer(SMTPTransport.java:1282)
    [STDERR]      at com.sun.mail.smtp.SMTPTransport.protocolConnect(SMTPTransport.java:370)
    [STDERR]      at javax.mail.Service.connect(Service.java:275)
    [STDERR]      at javax.mail.Service.connect(Service.java:156)
    [STDERR]      at javax.mail.Service.connect(Service.java:176)
    [STDERR]      at com.myapp.Mailer.sendMsg(Mailer.java:45)
    [STDERR]      at com.myapp.MailController.doPost(MailController.java:42)
    [STDERR]      at com.myapp.MailController.doGet(MailController.java:26)Why am I getting this java.net.ConnectException: Connection refused exception?
    Happy programming,
    Mike
    Edited by: mwilson72 on Aug 21, 2009 4:49 PM

    Hi Peter,
    Nice to hear from you again!
    Per your advice, this is what my mail-service.xml config file looks like now:
    <?xml version="1.0" encoding="UTF-8"?>
    <server>
      <mbean code="org.jboss.mail.MailService" name="jboss:service=Mail">
      <attribute name="JNDIName">java:/Mail</attribute>
      <attribute name="User">user</attribute>
      <attribute name="Password">password</attribute>
      <attribute name="Configuration">
         <configuration>
            <property name="mail.store.protocol" value="pop3"/>
         <property name="mail.transport.protocol" value="smtps"/>
            <property name="mail.smtp.starttls.enable" value="true"/>
            <property name="mail.smtps.auth" value="true"/> 
            <property name="mail.user" value="user"/>
            <property name="mail.pop3.host" value="pop3.gmail.com"/>
            <property name="mail.smtp.host" value="smtp.gmail.com"/>
            <property name="mail.smtps.port" value="465"/>
            <property name="mail.from" value="[email protected]"/>
            <property name="mail.debug" value="true"/>
         </configuration>
       </attribute>
       <depends>jboss:service=Naming</depends>
      </mbean>
    </server>Now, when I restart JBoss and point my browser to:
    https://localhost:8443/myapp/sendmail
    I get this exception:
    [STDOUT] DEBUG SMTP: useEhlo true, useAuth true
    [STDOUT] DEBUG SMTP: useEhlo true, useAuth true
    [STDOUT] DEBUG SMTP: trying to connect to host "localhost", port 465, isSSL true
    [STDERR] javax.mail.MessagingException: Could not connect to SMTP host: localhost, port: 465;
      nested exception is:
         java.net.ConnectException: Connection refused
    [STDERR] at com.sun.mail.smtp.SMTPTransport.openServer(SMTPTransport.java:1282)
    [STDERR] at com.sun.mail.smtp.SMTPTransport.protocolConnect(SMTPTransport.java:370)
    [STDERR] at javax.mail.Service.connect(Service.java:297)
    [STDERR] at javax.mail.Service.connect(Service.java:156)
    [STDERR] at javax.mail.Service.connect(Service.java:176)
    [STDERR] at com.myapp.Mailer.sendMsg(Mailer.java:45)
    [STDERR] at com.myapp.MailController.doPost(MailController.java:42)
    [STDERR] at com.myapp.MailController.doGet(MailController.java:26)Does anyone know what I am possibly doing wrong? Is it my code or is it the config file?
    -Mike

  • "This message cannot be sent at this time."  I have been getting this pop-up for 3 days when trying to send out mail.  I don't know what to do!  I cannot send mail from this account on any ISP. Please help!

    "This message cannot be sent at this time."  I have been getting this pop-up for 3 days when trying to send out mail.  I don't know what to do!  I cannot send mail from this account on any ISP. Please help!

    lots of people seem to be havgin a problem sending email from iCloud webmail.
    does your email address have uppercase characters in it?
    if so, try creating an alias in lowercase (go to preferences in iCloud webmail and select 'accounts') and see if email sends okay from that

  • When trying to send E-mail via AOL i get the message "rejected by the server because it does not allow relaying" I have checked settings as per answers to similar question

    When trying to send E-mail via AOL i get the message "rejected by the server because it does not allow relaying" I have checked settings as per answers to similar question

    From which account does the email not send?  When sending from an account, the iPad will first try to use the aoutgoing server for that account.  If it can't it will try the other accounts listed.in the setting on the iPad for that account.  It soulds like the server for the account is not working and that the alternate server is resjecting the messag since it did not originate ffrom the account associated with that server,  That is to prevent sending spam.

  • When trying to send e-mail I get an error message:

    When trying to send e-mail I get an error message:Can´t send message.
    It was not accepted by the server because it (the server?) does not allow forwardin.

    Check the outgoing mail server setting. Make sure that your username and password are in there.
    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.

  • Error(-101) encountered when trying to send a mail

    Hi,
    I am trying to send a mail through Business One 2005A. When i click on the email icon, a pop up window appears that asks if i want to attach an edited report with the mail. when i click "Yes", i get an error message error(-101) encountered. but if i click "No", i dont get that error. Can anyone please let me know what this error is all about?
    Regards,
    Harsh

    Hi Fulvia,
    This could be caused by folder permissions. Try creating a new share on the server (I typically create a share off the root of the drive, called something like B1_MAIL or SBO_MAIL), granting Full Control to all domain users and then mapping your attachments path in General Settings to this new folder. If this solves the problem then you can tighten up the security to fit your requirements afterwards.
    Hope this helps,
    Owen

  • Rejected password when trying to send e-mail

    When I try to send mail, I get a 'rejected password' message no matter how many times I reenter the password. What could be the problem? I lost one e-mail account when I did an upgrade to high speed about a week ago, and haven't been able to use my new e-mail account to send e-mail messages. I can receive messages using my new account and think all of the server information is correct---all in all-- a confusing mess.

    Yes, Bj,
    I'm using Apple Mail version 3.6.
    Where exactly do I put the fully qualified 'user name'?
    I have three columns at the top of the page, Description, Server Name already filled in, and In Use By Account already filled in.
    If I click on the Server Name I'm using, another option shows up at the bottom of the page, called Account Information, and below that a place to type in Description. Is that where I'd type my full e-mail address?

  • DMP when trying to send a mail

    Hi Experts
    My client is on 8.81 PL04 and for only one of the users, when they try send an internal mail, it gives the following error:
    Documents settings V Lettie\Local settings\applications data \ sap \ sa application has a problem
    Diagnostic file c:\documents and settings\Lettie\local settings business one\sap business one 20110623160654.dmp was created. Please contact support and attached diagnostic file.
    Your assistance would be greatly appreciated.

    Hi,
    Also to add to my comments, the dump file generated could be related to many factors like, the memory, the number of applications running on the client, add-ons etc. If this is one of I would suggest you to close all applications, clear the temp files , log back in and try. SAP will only investigate if the issue is occuring everytime and should be reproducible and there is a long process before you can log a message with SAP on dump file.
    regards
    Johnson

  • PSE 7 stops working when trying to send e-mail

    I am running PSE 7, Vista 64.  When I try to send a pic using e-mail attachment thru Adobe e-mail svc (AOL e-mail account), PSE 7 crashes.  I get a Windows msg saying the PSE 7 stopped working & Windows closes PSE 7.  I can see the e-mail msg, but no go.  Help.

    Check the outgoing mail server setting. Make sure that your username and password are in there.
    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.

  • No Send button when trying to send new mail

    This just started yesterday, when I open the new mail dialogue to send an e-mail there is no toolbar with the "send, save etc." buttons. So there is no way for me to send the e-mails that I'm drafting. I can send replies to emails but not when I am writing a new e-mail. Please help! I use e-mail a lot with my job and this is becoming a problem!

    KerryJ wrote:
    This just started yesterday, when I open the new mail dialogue to send an e-mail there is no toolbar with the "send, save etc." buttons. So there is no way for me to send the e-mails that I'm drafting. I can send replies to emails but not when I am writing a new e-mail. Please help! I use e-mail a lot with my job and this is becoming a problem!
    in a new message window click on the little oval in the upper right corner.

  • When trying to send a mail, selecting attachement fails with no error.

    I imported lots of folders form Kmail (KDE3.5/ trinity) on a previous version (don't remember which one) of Thunderbird.
    All worked fine. (I was able to send a variaty of files in email attachements (.xls, .zip, .txt and also files with no extension with no trouble)
    Somewhen two weeks ago I updated Thunderbird and it would not allow me to attach files to a mail I want to send.
    This means: --click on the button to send a new mail.
    --typing a email adress
    --typing a subject
    --typing 'hello' into the text field
    --clicking the button to attach a file
    --selecting a text file, picture, .zip, binary and click 'open' in the file selector
    == nothing changes in the email window to show that a file has been attached and also on sending the mail the receiver does not receive a mail.
    reverting to older version of thunderbird does not seem possible as it appears that there is no link to older packages on thunderbird downlaod site?
    where did I go wrong?

    I doubt it's a version problem. But I don't run Linux any more.
    Old versions can be found here:
    http://ftp.mozilla.org/pub/mozilla.org/thunderbird/releases/

  • Send THAI mail using JavaMail to Lotus Notes (URGENT)

    Hi all
    I experienced the problem when I try to use Javamail to send mail that contains THAI text to Lotus Notes . When I read my mail in Lotus Note,I cannot read it !! . What should I do ?
    Please suggest .
    Regards
    Chairat Tiajanpan
    E-Mail : [email protected]

    � hello!
    Do you know how can I do it? I am desesperated. Please help me.
    I want to send a mail to lotus notes using a Java class.
    What i need to install in my computer for running the class??
    Sorry for my english. I am spanish and i speak english very bad.
    Thanks!!

  • TS2998 Help! My Mac mail uses another person's name in stead of mine in the "from" heading when trying to send e-mail. How can I fix this?

    Mac mail started using another person's name instead of mine. In the "From" line it shows someone other than me so the receipient will not know I am sending them an e-mail. HELP!, This is crazy. Is there a fix?

    Does this problem happen EVERY time you send an email?
    Do you see the wrong FROM entry before you hit the send button? Or does the recipient report seeing another name other than yours?
    Do you recognize the incorrect name being shown? Is it something you or someone else using your machine have ever used? Is it a name you have never heard of before?
    Go to your SENT folder in Apple Mail. What do you see when you open one of your SENT emails, in the FROM slot? Is the name correct or incorrect?
    Also, I don't understand your comment "I noticed it when I try to send a link via e-mail to another person." are you saying that when you paste a link into an email to someone that your name in the FROM field changes? Where are you putting the link, in what place in the email?

  • Error when trying to send e-mail

    When running the following code:
    import oracle.ifs.common.IfsException;
    import oracle.ifs.common.*;
    import oracle.ifs.beans.LibraryService;
    import oracle.ifs.protocols.email.beans.Mailbox;
    import oracle.ifs.adk.mail.IfsMessage.*;
    import oracle.ifs.adk.mail.*;
    import oracle.ifs.server.*;
    public class test
    public static void main(String[] args)
    try
    LibraryService service = new LibraryService();
    CleartextCredential me = new CleartextCredential("system", "manager");
    ConnectOptions options = new ConnectOptions();
    options.setServiceName("IfsDefault");
    options.setServicePassword("manager");
    options.setLocale(Locale.US);
    LibrarySession session = service.connect(me, options);
    DirectoryUser user = (DirectoryUser) session.getDirectoryUser();
    if (user.isAdminEnabled())
    session.setAdministrationMode(true);
    IfsMessage msg = new IfsMessage(session);
    msg.setToHeader(new String[] {"[email protected]"});
    msg.setFromHeader(user);
    msg.setContentType("text/plain");
    msg.setSubject("iFS email test message");
    msg.setBody("Hello! This is a test. If you got this, something is working right.");
    msg.send();
    catch (IfsException e)
    e.printStackTrace();
    ...we get the following message:
    java.lang.ClassCastException: oracle.ifs.beans.TieFolder
    at oracle.ifs.adk.mail.IfsMessage.<init>(Compiled Code)
    at oracle.ifs.adk.mail.IfsMessage.<init>(Compiled Code)
    at test.main(Compiled Code)
    Thanks in advance for any ideas you may have.

    This code snippet works for me... It places the message in the system outbox.
    Can you check that your system outbox exists
    at /ifs/outbox
    and that it is an instance of 'FOLDER' and the that the ACL on it ' is protected (system)'.
    public void doSomething(LibrarySession ifs)
    throws IfsException
    IfsMessage msg = new IfsMessage(ifs);
    msg.setToHeader(new String[] {"[email protected]"});
    msg.setFromHeader(ifs.getDirectoryUser());
    msg.setContentType("text/plain");
    msg.setSubject("iFS email test message");
    msg.setBody("Hello! This is a test. If you got this, something is working right.");
    msg.send();
    null

  • Toolbar missing when trying to send email; must use alt, file, send

    Please tell me how to restore the toolbar on the "write email" function

    Open a Write Window
    Do you have a Menu Bar with File-Edit-View etc?
    If not press the alt key or F10 to make it appear.
    From the Menu Bar select View-Toolbars and turn the missing tool bar back on.
    Send is on the Composition Toolbar.

Maybe you are looking for

  • Creation of BP relationship " Has the responsible Scrapper" in CRM BP

    Hi, I am trying to create a BP relation ship " Has the responsible Scrapper" using the BAPI: BAPI_BUPR_RELATIONSHIP_CREATE between two BPs say BP1 to BP2 with the rel.type code as CRMS03. However it is creating the relation ship as "IS responsible sc

  • 4:3 to 16:9 .....and then to 4:3...aaargh!

    I'm stumped but it might be something simple I film in 16:9 Edit in iMovie.....share......it comes out 4:3 But When I do get it at 16:9 (using expert settings) it plays in 4:3 in iDVD preview. Any ideas? I'm wasting hours here!! Thanks in advance Pet

  • Do all namespaces have to live in the 'DFSRoots' folder?

    Running through DFSN PS commands for the 70-411... My question is, do all DFS namespaces have to have their root shared folder in the 'DFSRoots' folder? Working through the 70-411 Exam Ref handbook, and entering.. New-DfsnRoot -TargetPath \\trey-dc-0

  • External CD drive for power mac 8100

    I have an 18 year old power mac 8100/80 AV.  It has an internal CD drive that is read only.  I need a cd drive that is read/write so that I can copy thousands of files off the mac.  I'm assuming that an external drive may be the best route, rather th

  • Why is my computer not compatible with Miracast?

    So I built a brand new computer and it runs Windows 8.1 Pro right now, but it apparently doesn't support Miracast, because when i go to Project i don't see "add wireless display" button, can you please explain to me why my Windows 8.1 pro doesn't sup