Code for mailing from behing a proxy using Authentication

Dear friends,
I have found several requests regarding the mailing from behing a firewall/proxy with Authentication.. So here is the entire code for the same..
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
import java.util.*;
import javax.mail.*;
import javax.mail.event.*;
import javax.mail.internet.*;
public class MailClient extends Frame{
static String mailHost="proxyAddress";
public MailClient() {
public static void main(String[] args) {
Properties properties=new Properties();
properties.put("mail.smtp.host",mailHost);
properties.put("mail.smtp.auth","true");
Session session=Session.getDefaultInstance(properties,new MyAuthentication());
try{
Message msg=new MimeMessage(session);
InternetAddress address[]={new InternetAddress("toAddress1.domain.com")};
msg.setRecipients(Message.RecipientType.TO,address);
msg.setSubject("Test Mail");
msg.setFrom(new InternetAddress("[email protected]"));
msg.setContent("Please reply.. This is a java mail using Authentication
technique..","text/plain");
Transport transport=session.getTransport("smtp");
transport.connect();
transport.sendMessage(msg,msg.getAllRecipients());
}catch(Exception e){e.printStackTrace();}
Hope this helps..
regards Stallon
class MyAuthentication extends Authenticator{
public PasswordAuthentication getPasswordAuthentication(){
return new PasswordAuthentication("userName","password");
}

Hi stallon,
Thanks for ur reply.Actually my application is at server2. I have an account in server1 and sending mail from server2. server1 requires authentication to send it to server3. Though we provide it is not accepting.There no errors while execution but mail couldn't be send.
Please help me as soon as possible.
Thanks in advance,
bdurvasula
//debug code.
DEBUG: getProvider() returning
javax.mail.Provider[TRANSPORT,smtp,com.sun.mail.smtp.SMTPTransport,Sun
Microsystems, Inc]
DEBUG SMTP: useEhlo true, useAuth true
DEBUG: SMTPTransport trying to connect to host
"host", port 25
DEBUG SMTP RCVD: 220 host ESMTP
server (Netscape Messaging Server - Version 3.6)
ready
Thu, 21 Jun 2001 14:23:15 +0800
DEBUG: SMTPTransport connected to host
"host", port: 25
DEBUG SMTP SENT: EHLO rao
DEBUG SMTP RCVD: 250-host
250-HELP
250-EXPN
250-ETRN
250-PIPELINING
250-DSN
250 AUTH=LOGIN
DEBUG SMTP SENT: MAIL FROM:<[email protected]>
DEBUG SMTP RCVD: 250 Sender
<[email protected]>
Ok
DEBUG SMTP SENT: RCPT TO:<[email protected]>
DEBUG SMTP RCVD: 250 Recipient
<[email protected]> Ok
Verified Addresses
[email protected]
DEBUG SMTP SENT: DATA
DEBUG SMTP RCVD: 354 Ok Send data ending with
<CRLF>.<CRLF>
DEBUG SMTP SENT:
DEBUG SMTP RCVD: 250 Message received:
7745C8DA90B.AAA27D7
DEBUG SMTP SENT: QUIT
//now i am sending the mail that was sent by my server
This Message was undeliverable due to the following
reason:
Your message was not delivered because the
destination
computer
refused to accept it. The error message generated
by
the server
is reproduced below.
Non-local addressee. We do not relay!
Please reply to Postmaster@mailserver .if you feel
this message to be in error.Thanks once again
bdurvasula

Similar Messages

  • Picking mails from a particular sender using mail sender adapter

    Hi Everyone,
    I want to create a scenario in which i want to pick mails from a particular sender and send it to XI.
    I don't want all the unread mails to be sent to XI but only those belonging from a particular sender.
    How should i configure the mail sender adapter to achieve the same.
    Thanks and Regards
    Rahul Nawale

    Hi,
    there are two ways to do that:
    not standard:
    create a java proxy which will check your maibox for mails
    from only one particular sender and then send messages
    to the xi
    more standard:
    create a new accound and redirect your mails from a particular sender from the main mailbox to this new one
    and poll from this new one only...
    this way you'll be able to use atandard mail adapter
    with no changes at all
    Regards,
    michal
    <a href="/people/michal.krawczyk2/blog/2005/06/28/xipi-faq-frequently-asked-questions"><b>XI / PI FAQ - Frequently Asked Questions</b></a>

  • HT4480 I have redemption codes for FCP from my university - how many machines can I install on?

    I have redemption codes for FCP from my university - how many machines can I install on?

    Do you have these codes because this will be your app? Or is this a "loan" from the school to install on your machine? Do you use your own Apple ID to redeem the code and install the app?
    If it is your app, then you may install it on as many Macs as you own or have in your control.

  • How to fecth the contents of a mail from the server by using jsp

    hi
    Can any body tell me how to fetch the contents of mail from the server by using javamail api...please send me code if some one have
    bye.

    hi
    Can any body tell me how to fetch the contents of mail from the server by using javamail api...please send me code if some one have
    bye.

  • Need code for Sales order creation in oops using xi as integration server

    Need code for Sales order creation in oops using xi as integration server.

    hi rocky,
              could you pls give a bit explanation on what you are expecting.
    regards,
    Pavan

  • I get a message IOS 6.1.2 failed verification because you are no longer connected to the internet .  i checked my connection to internet and its fine for mail and all other internet use only keep getting nowhere fast.

    i get a message IOS 6.1.2 failed verification because you are no longer connected to the internet .  i checked my connection to internet and its fine for mail and all other internet use only keep getting nowhere fast

    Just Power off your Iphone wait for 10 seconds and then power on again and got to settings and software update it will download the update once again and it will work fine.

  • Sending E-mail from BI Publisher without using Bursting Option

    Hi All,
    “While clicking on Send Button and selecting E-mail as Delivery option in BI Publisher for a particular Report, we want that To, CC, BCC  and the Body part should get populated  with the Email id’s and Static text(for Body )  from database . We know that it can be done if we use the option of Bursting but we don’t want to use bursting . Is there any way (SQL Query or API’s) where we can achieve this option of populating the email id’s and body dynamically
    while clicking on the Send button on the BI Publisher Screen. Please Suggest.”

    Hi,
    Looking at the above link it seems thatit is for XML publisher in EBS rather than for a standalone BI publisher. Please let me know how to acheive the steps mentioned in the blog while working on standalone version BI publisher.
    Thanks
    Sunil

  • Creating a server rule that watches for mail from an external user

    We need to create a rule that will watch for incoming mail from an external domain and then forward that mail to an internal distribution list. I don't want it to be tied to an Outlook user. Is this possible? I can't seem to find a way to do this. 
    Orange County District Attorney

    Hello,
    Please make sure your exchange version.
    If you use exchange 2007/2010, there is no this transport rule to realize it. But you can create a transport rule( from users inside or outside the organization; copy the message to addresses) to copy incoming mail from an external domain to your distribution
    list.
    If you have any feedback on our support, please click
    here
    Cara Chen
    TechNet Community Support

  • How to code for select all& deselect all?using menu buttons

    hai,
    i have generated a report with a single field from a database table and
    i have a checkbox for each record/item in the report.
    i need help in the following ..
    now that i have menu buttons say "select all" and "deselect all"..
    if select all is clicked then all checkboxes should be selected.
    if deselect all is clicked, then all checkboxes should be deselected
    i know that we have to use functional code and use case sy-ucomm etc.
    when "selectall"  etc..
    can someone help me how to code for this to work exactly?

    it did not work for the code u had suggested...
    plz check it out and send me the exact working code..
    REPORT  ZINTRACTIVE_PROJ                        .
    TABLES : SFLIGHT.
    DATA : BEGIN OF IT OCCURS 0,
           CARRID LIKE SFLIGHT-CARRID, FLDATE LIKE SFLIGHT-FLDATE,
           END OF IT.
    DATA : BOX TYPE C,
           LINE TYPE I.
    SELECT CARRID FLDATE FROM SFLIGHT INTO TABLE IT.
    LOOP AT IT.
    WRITE : / BOX AS CHECKBOX, IT-CARRID.
    ENDLOOP.
    LINE = SY-LINNO .
    SET PF-STATUS 'SELECT'.
    AT USER-COMMAND.
    CASE SY-UCOMM.
      WHEN 'SELECT'.
          DO LINE TIMES.
            READ LINE SY-INDEX FIELD VALUE BOX.
            IF BOX = 'X'.
               NEW-PAGE.
               WRITE : / IT-FLDATE.
            ENDIF.
          ENDDO.
      <b>WHEN 'SELECTALL'.
          LOOP AT IT.
            IT-CARRID = 'X'.
            MODIFY IT TRANSPORTING CARRID WHERE CARRID = IT-CARRID.
            EXIT.
          ENDLOOP.
      WHEN 'DESELECTALL'.
          LOOP AT IT.
            IT-CARRID = ''.
            MODIFY IT TRANSPORTING CARRID WHERE CARRID = 'X'.
            EXIT.
          ENDLOOP.</b>ENDCASE.

  • I need a code for backup from oracle forms 10.1.2.3g

    Please if any body can help me that what code will I use to get a backup of my db from forms, I am using 10.1.2.3 version of forms with 10g db.
    Thank you.
    Hina

    Hello,
    Backing up a database is not the work of an Oracle Forms user. It has to be done by a Database administrator. There are several ways to backup a DB, cold or hot, with export/import, by copying the datafiles, ...
    None of this methods have any relation with Oracle Forms, so have to be launched as external programs.
    If the client has those utilities installed locally, you should use the Webutil Client_Host() built-in to start them.
    Francois

  • Content-Transfer-Encoding for mail from Portal

    Hi,
    I work on Portal 7.0 SP 12.
    Do You know how to change encoding (Content-Transfer-Encoding) for mails send from portal by users (ex. from Collaboration Launch Pad) ?
    Regards,
    Jarek

    Thank you

  • How to get the embed html code for my webpage so I can use it on eBay listings?

    Hi, I already created a Muse webpage, but when i export it as html I get a code that is not compatible with eBay because eBay won't allow "cookies" nor "iFrame" on a listing.. is there a way around so I can get a working html code for eBay? I'm new at this, I don't have coding knowledge. I've never use Dreamweaver either, Muse is appealing since is user friendly, so any good explanation would be greatly appreciated. Thank you.

    Hi, muse is an application made for create websites without coding skills, not to replace any possible use of HTML. If you would like to adapt your code for other uses, like CMS integration, Newsletters, build mobile apps, and other, you will need some coding skills.

  • How can i import my sent e-mails from before i started using thunderbird so that they can all be viewed in thunderbird?

    I would like to import all my sent items from before i started using thunderbird into thunderbird. I never used an "outlook" programme before this, so all my previously sent emails are on a web-based server. Is there anyway in which i can import all these?
    == i tried to import all my sent mails into thunderbird

    Thunderbird support is over here.
    [http://www.mozillamessaging.com/en-US/support/]
    or here:
    http://forums.mozillazine.org/viewforum.php?f=39

  • Define Alert for mail from specific sender on E5-0...

    Hi All
    I'm supposed to receive pager on my E5-00 overnight so I wanted to define a alert (ringtone) when a mail from a specific user is received is that possible?
    Regards 

    You would have to set up a server-side filter which moves everything which isn't from this sender to another folder which you'd have to look at in the morning, enable it every night and disable it every morning.

  • Changing sender id for mail from vf03

    Hi Experts,
    When I send a billing document from VF03 to a customer, the e-mail address is read from my sap user (SU01). I would like an e-mail address for each billing type, but I don't now how to change "mail_sender" parameters in the smartforms (ZRLB_INVOICE program).
    Can you help me, please?
    sharing piece of code , where i think could make a difference ,
    PERFORM set_print_param USING    ls_addr_key
                                          ls_dlv-land
                                 CHANGING ls_control_param
                                          ls_composer_param
                                          ls_recipient
                                          ls_sender
                                          cf_retcode
    here the sender is is_sender : DATA: ls_sender             TYPE swotobjid.
    swotobjid - structure contains
    LOGSYS
    OBJTYPE
    OBJKEY
    DESCRIBE
    i dunno how it has 2 b changed. right now i guess it's getting filled with user name data from su01.
    Thanks.
    Arun

    Did you check the subroutine set_print_param. This sub routine should tell you the logic on how the data for sender is used. Use your own custom logic to fill the sender.

Maybe you are looking for

  • Home Sharing Problem: "You do not have permission to access the requested resource"

    This problem has been posted numerous times here with not one single answer that I can find. Not only does it take about fifteen minutes for Home Sharing to load on my iPad, once it does load I get the "You do not have permission to access the reques

  • Error in Posting doc using FBV0

    Hi, We are in the process of implementing Roles and authorizations in one of our client- While UAT we are facing one issue- Eg, User uatuser1 is an execuive and having F-63 and FV60 T-codes for perking documents So, this user perked two document doc1

  • File Content Conversion: Remove reserved characters from Content

    Hi PI Gurus, we're facing a little problem with FCC in File Receiver Adapter.  Sometimes the defined fieldSeparator ("|") comes within the field content. e.g. <?xml version="1.0" encoding="UTF-8"?> <ns0:Positions xmlns:ns0="http://test.com"> <Positio

  • Recursive item blocking

    How can I block or prevent the entry of recursive components in bill of material which is not header material. If I enter the material which is already available in bill of material, SAP should not allow the entry if the component is not headed item.

  • LV PDA 8.2 Need to install PNG support files if using Bitmaps?

    Hello All: I'm using 8-bit bitmaps in my LV PDA 8.2 Windows Mobile 5.0 app.  I found out bitmaps will not load unless I install the PNG support files into my PDA.  Is this a misnomer?  Should the PNG install files be called Image install files? The r