How to send the same message to two SMTP servers

hi,
I need to send a message to two different SMTP servers.
I want to avoid the creation of new MimeMessage with a new Session.
the only way I've found was to keep a reference to the Properties instance that was used in the Session creation, and modify its "mail.smtp.host" property.
Is there another way? I must be missing something.
thanks,
ofer

hi,
I've already found the solution, so I'll post it here.
first I'll explain the purpose:
I needed to send the same message to a normal email server, and (for some of the recipients) to a special SMTP server that is on a different machine.
the following code demonstrate the solution.
thanks for your help.
ofer
----------code---------------
public class MultipleSendTest {
private final static Session server1 = createSession("somesmtp_server.com");
private final static Session _server2 = createSession("another_smtp_server.com");
public static void main(String args[]) throws Exception {
//create the message
MimeMessage m = new MimeMessage(_server1);
m.setText("body text");
m.addRecipients(Message.RecipientType.TO, "[email protected]");
m.setFrom(new InternetAddress("[email protected]"));
//send
send(m, _server1);
send(m, _server2);
private static void send(MimeMessage message, Session session) {
//for logging only
String host = session.getProperty("mail.smtp.host");
try {
Transport transport = session.getTransport("smtp");
transport.connect();
transport.sendMessage(message, message.getAllRecipients());
System.out.println("sent to " + host);
transport.close();
} catch (MessagingException e) {
System.out.println("failed to send to " + host);
private static Session createSession(String host) {
Properties properties = new Properties();
properties.setProperty("mail.smtp.host", host);
return Session.getInstance(properties);
----------code---------------

Similar Messages

  • Send the same   message to two receivers with some  time difference..

    Hi
      I want to send the same message to Two receivers  with the slight time difference.. becuase  but not at the same time.. if the same time means.. just we can  specify the two receivers in the one receiver determination..
       but  if i want to send the   same message to Two  reveivers with the time difference means..(after sending the  message to first receiver.. after  some time gap.. i need to send the  message to second receiver..
      this type of scenarios how can we do.. is it possible to do with out BPM...  please suggest me the solution..
    Thanks
    Jain .P

    Hi Jain,
    With BPM you can easily do it.
    i am giving you the steps:
    1)first add a receive strep to get your message
    2)then, put a receiver determination step with a multiline receiver container element assigned to its Receivers property.
    3)then, put a block in dynamic mode(ie. ForEach/ParForEach mode) and assign the multiline receiver container element to its multiline element and assign a simple(single line) receiver container element to its current line property.
    4) add a send step within the block, choose Receivers List in its Receiver From property and choose the current line receiver element in its Receivers property.
    5) then add a wait step in the BPM, in its type select Wait Specified Time Period and then mention the duration in your desired time unit.
    **Reward points if helpful...
    --Sankar Choudhury

  • Using an IDOC sending the same message in two different format

    i have a message which i have to be sending from one SAP system to another, but the message should be split into 2 different formats using mapping and send to one receiver where the 2 messages are segregated using some ID number. here we will be using IDOC for sender.
    kalyan.

    Hi,
    I think you can go for the  multimapping(1:2) and not exactly splitting the message but mapping it one source to two different targets that need to be sent to one receiver...
    Just see these blogs on that..
    /people/jin.shin/blog/2006/02/07/multi-mapping-without-bpm--yes-it146s-possible
    /people/venkataramanan.parameswaran/blog/2006/03/17/illustration-of-enhanced-receiver-determination--sp16
    You need to go for enhanced interface determination.
    Thanks,
    Vijaya.

  • Can we send the same message two different recievers with sequence

    Hi,
    i am sending the same message to two different receviers without using BPM.
    now i require to send with sequence.is it possible without BPM?

    Hey
    There are two options for this
    First one is to use Wait step in BPM as other experts suggested.
    Second one is a dirty way around,what you can do is send the second message to a dummy receiver first(may be a file on your XI server),then design one bypass scenario which will pick up the file after a specified time interval(give the poling interval you want).
    i would go for BPM coz its pretty straight forward,but in case you want to avoid BPM then u can use the second approach
    for bypass scenario,have a look at the following
    How to send any data (even binary) through XI, without using the Integration Repository

  • My mac mail on just keeps sending the same messages even after deleted and shows thousands of emails supposed to be coming in

    My mac mail on just keeps sending the same messages even after deleted and shows thousands of emails supposed to be coming in

    If you have a backup, you can restore the e-mails. Go to Finder and select your user/home folder. With that Finder window as the front window, either select Finder/View/Show View options or go command - J.  When the View options opens, check ’Show Library Folder’. That should make your user library folder visible in your user/home folder. Library/Mail/V2.
    Thanks to leonie for some information contained in this.

  • HT4059 I cant download a previously purchased book ...yes I tried tapping the cloud. It just send the same message.

    I purchased a book from itunes. I downloaded the preview book but it wont let me dounload the whole book. I keeps telling me I have already purchased and to go to purchases and tap download. I did, and taped the cloud. It keeps sending me back to the same message. What can I try now???

    Welcome to the Apple Community.
    You'll need to delete the partial book first.

  • HT5395 I have a mac , but i have no idea what version it is.. its all white and i just got it .. i have one problem , i have no idea how to send the text messages ? it keeps telling me i need to have some aol account .so somebody please help me understand

    im just trying to find out how to send a message on the mac ...... someone please help ! thanks so much !

    HI,
    This is fairly generic (for iChat 4) although some links are out of date.
    Start at the second menu down that says "Get a Screen Name"
    http://www.ralphjohns.co.uk/versions/ichatvers4/howtos4.html
    iChat 5 is virtually no different
    iChat 6 adds the Yahoo option.
    As has been said more specific info from yourself will enable a much more detailed reponse from us.
    10:44 pm      Wednesday; July 24, 2013
      iMac 2.5Ghz 5i 2011 (Mountain Lion 10.8.4)
     G4/1GhzDual MDD (Leopard 10.5.8)
     MacBookPro 2Gb (Snow Leopard 10.6.8)
     Mac OS X (10.6.8),
     Couple of iPhones and an iPad
    "Limit the Logs to the Bits above Binary Images."  No, Seriously

  • How to run the same license on two computers?

    Hello,
    I have searched around a bit for answers to my questions without luck so far.
    I have used Adobe Lightroom 3 & 4 on my computer for years. Now I have purchased a laptop computer as well. I am the only user of both computers. As I understand the end user license agreement, I am allowed to use the same license on both of my computers.
    Is this straightforward? Do I just install LightRoom 4 with the serial number from the purchase? LR4 was an upgrade from LR3. Do I need to install LR3 first, or just use both serial numbers?
    I will also like to upgrade my standalone computer from Windows 7 to Windows 8. I have actualle tried the upgrade process, and was told it failed, and that I need to do a complete (fresh) installation of Windows 8 (after formatting the computers disk).
    Will I be able to do this? My preferred "end result" is running LR4 on both computers with Windows 8, although a fresh installation of Windows 8 on the standalone computer.
    I am also considering purchasing Adobe Acrobat. Will I be able to run that as well on both computers?
    What if I replace the standalone with a new computer one day - will I be able to move the license from the "old" one?
    I would appreciate an answer to this post.
    Best Regards,
    Svein A. Martinsen

    As you already indicated your awareness, you are allowed to install and activate Adobe software on two machines.  You should only need to install and then activate.  If you have the discs, then go that way.  I f you do not have discs, download the version(s) and use your serial number from your original purchase to activate.
    As far as changing from Windows 7 to Windows 8 goes, that's generally beyond the calling of folks here.  I personally would not upgrade an OS, having done it once in the past and regretting it every day after that - I now prefer to live with what came with the machine.  You might find older software is not compatible with Windows 8 and there is nothing anyone here can do to change that.

  • Every time I send a text, it sends the same message twice

    I have had my phone for about a week now and every time I send a text to someone it sends the message twice.
    I have no idea why this is happening. What can I do to stop it from sending the message twice?

        Hi samglow!
    Let's take a look into this, we want your messages sent only once. Let me ask...are you using a 3rd party application for messaging, or the app that came with the phone? Are you receiving messages just once, or more than once? What's the software version of your device?
    To troubleshoot, please remove the SIM from the device, and power off/on. Then, test again.
    Thanks!
    Christina_VZW
    Please follow us on twitter @VZWSupport

  • N96 repeatedly sending the same message

    My N96 clearly has a serious issue, well its serious to me given the huge amount of money it is costing me to send a text message right now. When I send  a message, it continues to keep sending it over and over and over and over again, every few minutes, despite the recipient getting the first message and replying.
    I've taken the battery out and left it out for a day, put it back and it does it all over again.
    Can anyone offer a solution to this insane problem?
    thanks in advance

    Its neither in the Outbox or the Sent box. Turning the phone off stops the sending, turning it back on restarts the sending.
    I've tried a *#7370# reset but do not know yet if the problem persists. I am kind of reluctant to put my contract SIM back in as it was repeatedly sending the SMS to an international number (every 3 minutes precisely according to my provider billing account) and its cost a lot of money so far. But when I replaced that SIM with another PAYG SIM the sending did not continue even before the reset. So, its doubly confusing.
    What are the codes for the various resets?
    Many thanks for your reply, hope you had a great christmas so far

  • How to send HTML as message body using SMTP

    I need to send HTML formatted emails. I used the Report Generation Toolkit to build my HTML document and make sure I had all of the formatting right. Then I modified the Save Report To File.vi to also give me the HTML text string on an output connector and I wire this string to the message input on the SMTP Email Send Message.vi.
    I receive the email OK, but all I see is the HTML code in the message body. What can I do to make sure that the email displays the message correctly.
    I use Outlook and I know it will receive and display HTML emails, I get them all the time.
    I would appreciate any help.

    Hi Dgw,
    it is similar. You must change message MINE content-type to "text/html" type. Because everyone document in email protocol have set MINE content-type. It is inforamtion for email servers and for email cients (Thunderbird, Outlook and etc.)
    For sendning mail with attachments you must use and modified "SMTP Send Multiple Attachments.vi" - if you can do backup of this VI and subVIs. Open Diagram of "SMTP Send Multiple Attachments.vi" after "SMTP Send Multiple
    Attachments Message.vi" and ther is VI "MIME Send Data Attachment.vi" - have control "MIME content-type" but code from NI don't use it.
    And like as my previous message, create new string control "MINE content-type" and take out this control to "main" Email VI.
    And embedd
    ed file you set up in control-cluster "attachments". I don't test it, but I mind thet must working :-)
    Have nice day
    JCC
    Attachments:
    email.jpg ‏70 KB

  • My iPhone 4 keeps on sending the same message

    Last summer I exchanged sms with a contact of mine who has a Blackberry. What happened since then is that she receives one of the messages I sent to her then once a month. I canceled from the conversation that message, but it didn't help. I changed my carrier in January, and also that had no effect.
    Can someone help me (or, better, her)?

    Basics from the User Guide are restart, reset, restore from backup, restore as NEW.  Try each of these until your problem is resolved.

  • Can I use the same database for two WSUS servers?

    Hi Folks,
    Our HQ WSUS database is on a dedicated SQL Server 2008 in HQ. We are planning to set up a replica WSUS server in a branch office (centralized management mode). But we want to check the WSUS reports (e.g. computer/update status) only from the HQ instead
    of each branch. I have two questions.
    I should not install the SQL Server in Branch, and specify the HQ SQL Server as the Branch WSUS server database, right? In this case, I can check WSUS reports of both HQ and Branch from HQ, right?
    Can I use a specific update source (e.g. Microsoft Update or other WSUS upsteam servers) for Branch WSUS server instead of HQ WSUS server even it's a replica WSUS server?
    Thanks,
    高麻雀

    Regarding to "If the branch office server is intended to be a replica server, then it must be configured with the HQ WSUS server as the update source", does it mean my branch WSUS server is only able to get the patches from my HQ WSUS server?
    That is the fundamental premise of a downstream replica server.
    Isn't it able to get the patches from Microsoft Update or other WSUS servers?
    Well, here we may have a terminology challenge... so let me take a step back and answer this way:
    A WSUS server obtains *updates* via the process of synchronization. Updates can be synchronized from one of two sources: Microsoft, or an Upstream WSUS Server.
    Additionally, updates have a concept of APPROVAL. Approvals can be obtained from an Upstream WSUS Server when the server is configured as a REPLICA server; otherwise, Approvals are created at each individual WSUS server.
    Finally, updates have FILES. Files can be obtained from Microsoft or the Upstream WSUS server, and this configuration option is absolutely independent of where the updates and/or approvals come from.
    Please note: All of this is exhaustively documented and discussed in the
    WSUS Deployment Guide. I would highly recommend reading it cover-to-cover.
    In this case, there will a a lot of bandwith cost on the leased line which is only 2Mbps and intended for critical business like VDI/ERP applications.
    A few thoughts here...
    First a 2Mb/sec link is more than adequate to support a WSUS server downloading update files from an Upstream WSUS Server.
    Second, using BITS you can configure when those files are transferred as well as how much of that 2Mb/sec is made available to the WSUS downstream server.
    Third... Patch Management IS a critical business function. Do not let it be treated as a step-child or the VDI/ERP functionally will be irrelevant.
    "after installing the replica server in the branch office, on the upstream server enable the option for Reporting Rollup", will the report information (computer/update status) be recorded in the HQ SQL Server?
    The detail reporting data for the clients of the downstream replica servers is physically stored in the upstream server's database.
    Lawrence Garvin, M.S., MCSA, MCITP:EA, MCDBA
    SolarWinds Head Geek
    Microsoft MVP - Software Packaging, Deployment & Servicing (2005-2014)
    My MVP Profile: http://mvp.microsoft.com/en-us/mvp/Lawrence%20R%20Garvin-32101
    http://www.solarwinds.com/gotmicrosoft
    The views expressed on this post are mine and do not necessarily reflect the views of SolarWinds.

  • DMS need to send the same document to multiple content servers

    Dear Experts,
    We are implemeting DMS with three content servers(A,B,C locations).We have requirement that need document must save on 3 content servers and user can see document from any one of them.
    As per understanding while create document ECC system ask which content server need to save,We can select one of content servers.
    Kindly give me answers for below questions
    - Is there any posibility to select multiple content servers which creating document?
    - Is there any posiblity to shared repository for 3 servers?
    Please advice on the requirement.
    Thanks in advace.
    Regards,
    Santhosh.

    Dear Santhosh...
    for this kind of scenario SAP Provide
    Content Servers and Cache Servers
    Any number of content servers can be installed in different locations. The contents are transferred directly between the client and content server. A cache is used to store copies of documents when they are accessed for the first time. As a result, the documents can be accessed again more quickly, since the contents are taken directly from the cache. Caching, however, must not be confused with replication.
    With caching, the original documents are stored in one location, namely on the content server. The copies in the cache can be replaced with newer content at any time.
    Follow the link ..it will help you
    http://help.sap.com/saphelp_nw04s/helpdata/en/02/804d3ccd6fba74e10000000a114084/frameset.htm
    http://help.sap.com/saphelp_nw04s/helpdata/en/7f/fba637fcf7dc39e10000009b38f8cf/frameset.htm
    http://help.sap.com/saphelp_nw04s/helpdata/en/21/f36c11389511d5992200508b6b8b11/frameset.htm
    for the installation process Content Servers and Cache Servers
    follow the link
    [SAP Content Server for Windows Installation Guide|http://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/cfa73246-0a01-0010-71b4-bc21ccb45c99?quicklink=index&overridelayout=true]
    or see this post...
    Content Repository & Content Category
    Regards
    Tushar Dave

  • HT201320 when i send an email using my hotmail address through outlook my contacts do not receive the mail. when i send the same mail through my iPad or iPhone no problem my contacts receive the mail. this only problem happens when i send mail with my mac

    I have a hotmail email address. I compose my mail useing MS outlook. when i send the mail to my contacts useing my macbook air,my contacts tell me there have not received the mail.
    when i send the same message with my ipad or iphone no problem my contacts receive the mail.
    what is the problem?

    Blair84 wrote:
    Double check your contacts email, and if its incorrect, go to their contact and change it and save it or you can delete the email you put in, and manually type it in.
    Hope this helps.
    How would that help the original poster?

Maybe you are looking for