Checking the mail status after sending it ??

Hi every body :-
I'm in my first steps in Java Mail and I need your helps.....
I'm using the following class to send mails to a certain reciepent ...It worked actually when the reciever mail address was correct (within my company domain)...but when I tried the following I failed can u please give ur suggestions ...
1)when I tried to send to wrong reciever in the correc domain, it gives no exception ....
2)when I want to send to external domain(@yahoo.com) it raises exception ==>550 5.7.1 Unable to relay for XXX
I want to be able to catch all of the exceptions ..but I don't know how ......
import java.io.*;
import java.util.*;
import javax.mail.*;
import javax.mail.event.*;
import javax.mail.internet.*;
public final class MailerBean {
     /* Bean Properties */
     private String to = "wrong_reciever@Correct_Domain";
     private String from = "test@Correct_Domain";
     private String subject = "My Mail Program";
     private String message = "Hi How are you..........";
     public static Properties props = null;
     public static Session session = null;
     static {
          /*     Setting Properties for STMP host */
          props = System.getProperties();
          props.put("mail.smtp.host", "mail server IP Address");
          session = Session.getDefaultInstance(props, null);
     /* Setter Methods */
     public void setTo(String to) {
          this.to = to;
     public void setFrom(String from) {
          this.from = from;
     public void setSubject(String subject) {
          this.subject = subject;
     public void setMessage(String message) {
          this.message = message;
     /* Sends Email */
     public void sendMail() throws Exception {
          if(!this.everythingIsSet())
               throw new Exception("Could not send email.");
          try {
               MimeMessage message = new MimeMessage(session);
               message.setRecipient(Message.RecipientType.TO,
                    new InternetAddress(this.to));
               message.setFrom(new InternetAddress(this.from));
               message.setSubject(this.subject);
               message.setText(this.message);
               Transport.send(message);
          } catch (MessagingException e) {
               throw new Exception(e.getMessage());
     /* Checks whether all properties have been set or not */
     private boolean everythingIsSet() {
          if((this.to == null) || (this.from == null) ||
          (this.subject == null) || (this.message == null))
               return false;
          if((this.to.indexOf("@") == -1) ||
               (this.to.indexOf(".") == -1))
               return false;
          if((this.from.indexOf("@") == -1) ||
               (this.from.indexOf(".") == -1))
               return false;
          return true;
     public static void main(String ss[])
          MailerBean mb = new MailerBean();
          try{ mb.sendMail();}
          catch(Exception ex1)
               System.out.println("Farah: Exception====> "+ex1.getMessage());
}

When you say "wrong receiver" do you mean an address that does not exist in the domain you sent the mail to?
If so, there is no way for you to check that when you send the mail, and you will not get an exception. It is possible that the domain's e-mail server may send a "bounce" message back to your server to tell you that the address does not exist there, but that happens later and there is no guarantee it will happen at all.

Similar Messages

  • I had an imap account in my iPad and my iPhone 4. They worked just fine till about Christmas. They act like they are checking the mail and it shows there is mail to come in, but it just goes back to saying checking mail.  Can't send mail either.

    I had an imap account in my iPad and my iPhone 4. They worked just fine till about Christmas. They act like they are checking the mail and it shows there is mail to come in, but it just goes back to saying checking mail.  Can't send mail either.

    Update to above question:
    Hello All,
    To anyone with the same problem described above, on THEIR iPad (if it is running iOS 7.0.2):
    Go to Settings; Mail, Contacts, Calendars; DELETE your *******@btinternet.com e-mail account, that you originally set up either using 'Other', or the 'BT' option which I am sure was in the list previous to the iOS 7 update.
    Then ADD a NEW account choosing YAHOO from the list of options. DO NOT USE 'OTHER'.
    Enter the correct details just as you (almost certainly) had already done in your previous attempts using 'other'.
    When you see the 'verifying......' and 'the blue ticks' you should be able to exit settings and open your mail app and then receive all your 'old' e-mails again, AND be able to SEND as well.
    All my 'old' e-mails, were NOT found in the 'old e-mail' folder though. THEY are still in my inbox.
    So this fix worked for me.
    After I deleted my account from 'OTHER' and put it in Yahoo, I like other people also ended up with more folders.
    I hope this works for you on YOUR Apple devices.
    Bob

  • Check The Job Status

    Hi SAPsimhas,
    My requirement is as below.
    I will loop through an internal table and create some files with background processing method.(JOB_OPEN,SUBMIT & JOB_CLOSE)
    Now once this job is triggered I need to check the status for that job after maximum 10 mins. Its not neccessary that each job will take 10 mins. only,It can be finished in 2 mins also.
    Once the job is finished then I will XCOM that file.
    So my question is how to code such timer which will check the job status for that job? I have a FM BP_JOB_READ which returns the job status.
    Reply is highly appriciated.

    Try this way
      do.
        call function 'SHOW_JOBSTATE'
          exporting
            jobcount         = p_jobc
            jobname          = p_jobn
          importing
            aborted          = v_aborted
            finished         = v_finished
            ready            = v_ready
            running          = v_running
            scheduled        = v_scheduled
          exceptions
            jobcount_missing = 1
            jobname_missing  = 2
            job_notex        = 3
            others           = 4.
        if v_aborted eq 'X'.
          exit.
        endif.
        if v_finished eq 'X'.
          select single * from tbtcp into wa_tbtcp1
                     where jobname eq p_jobn
                       and jobcount eq p_jobc.
          if sy-subrc eq 0.
            move wa_tbtcp1-listident to p_spono.
          endif.
          exit.
        endif.
        if v_count le 10.
          call function 'ENQUE_SLEEP'
            exporting
              seconds = 60.
          v_count = v_count + 1.
        endif.
      enddo.

  • URGENT : Error 5 when checking the job status

    Hello Forum,
    While monitoring the Process Chains in BW 3.1, I got the following message in the <b>Information </b>Pop-up:
    <b>Error 5 when checking the job status</b>
    Could you please tell me what it means?
    Thank you,
    its my duty to assign points,
    raj

    Hi,
    Are you able to view the log after refreshing and clicking the tick mark button on this message or is it not letting you go into the log itself.
    Can you directly go to Log view thru Tcode RSPCM and see. Once you are inside try to find where exactly the process failed.
    Thanks,
    JituK

  • Checking the connection Status

    Is anyone using the cocoaDev NetSocket? I try difficulty in checking the connection status using NetSocket...i open the socket and the connection, but when i'm perfmorming some action that waits for a server response, there's no automatic timeout that control if the connection is up or down after many seconds waited by the same action...

    We are using Outlook 2010
    I have removed the entry in the LAB using ADSIEdit following this procedure:
    http://exchangeserverpro.com/remove-default-public-folder-database-exchange-mailbox-database/
    This has resolved the issue there. Why are you opposed to me running this in Production?
    Thanks
    shapi
    I wanted to verify that you weren't using any org forms first!
    Since you are using Outlook2010, why not remove the PF distribution on that 2007 OAB as well?
    Twitter!: Please Note: My Posts are provided “AS IS” without warranty of any kind, either expressed or implied.

  • 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?

  • TS3899 Having trouble accessing my email account thru the mail app, after entering the account information in the settings page, hotmail returns with the error message " The user name or password for Hotmail is incorrect

    Having trouble accessing my email account thru the mail app, after entering the account information in the settings page, hotmail returns with the error message " The user name or password for Hotmail is incorrect". Help

    Hotmail is having problems:
    http://bostinno.streetwise.co/2013/08/15/hotmail-outage-hotmail-is-down-for-user s-still-photos/
    http://www.engadget.com/2013/08/14/outlook-outage/
    http://www.infoworld.com/d/applications/microsofts-skydrive-outlookcom-are-down- some-users-224940
    http://mashable.com/2013/08/14/outlook-down/
    http://techcrunch.com/2013/08/14/microsoft-acknowledges-outlook-com-messenger-sk ydrive-outages/

  • TF244069: An error occurred while checking the provisioning status of the reporting database schema for a PWA instance.

    The command TfsAdmin ProjectServer /RegisterPWA causes next error:
    TF244069: An error occurred while checking the provisioning status of the reporting database schema for a PWA instance.
    Project Server returned the following error: "Server was unable to process request. ---> The request failed with HTTP status 401: Unauthorized.".
     (type ProvisionException)
    Exception Stack Trace:    at Microsoft.TeamFoundation.Sync.Provisioning.ProvisionPwaDBSchema.HandleSoapException(SoapException soapException, String errorResourceString)
       at Microsoft.TeamFoundation.Sync.Provisioning.ProvisionPwaDBSchema.IsDBSchemaProvisioned()
       at Microsoft.TeamFoundation.Sync.Provisioning.ProvisionManager.Provision()
    I installed SharePoint 2013 and Project Server 2013 as farm and TFS 2012 and my account has permissions everywhere. I read article
    http://msdn.microsoft.com/en-us/library/gg412653.aspx and gave full permissions for TFS account to SQL and Project, Project app pool account to SQL, but still have an error.
    How can I find out what exactly permissions are not enough???

    The problem was in claims authentication. Changed to Windows and all worked out.

  • When I try to sign into iCloud from Windows PC I get the message "You can't sign in because of a server error." When I check the iCloud status, all is Green.

    When I try to sign into iCloud from Windows PC I get the message "You can't sign in because of a server error."  When I check the iCloud status, all is Green.  What is the fix?

    Hi spillgar,
    If you are having issues signing in to iCloud from your Windows machine, you may find the following articles helpful:
    iCloud: Account troubleshooting
    http://support.apple.com/kb/ts3988
    iCloud: If you can’t sign in to iCloud.com
    http://support.apple.com/kb/ph2611
    Regards,
    - Brenden

  • How can I check the return status of a request using URLConnection?

    Hi,
    I am using the classes URL and URLConnection to connect to a remote server and make a POST request. The code extract is:
    URL u = new URL("http://.....");
    URLConnection con = u.openConnection();
    con.setDoInput(true);
    con.setDoOutput(true);
    con.setUseCaches(false);
    con.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
    DataOutputStream out = new DataOutputStream(con.getOutputStream());
    out.writeBytes(........);
    out.flush();
    out.close();
    Next, I would like to check the return status of my request. I need to see if the server returned status 200 (OK) or an error (e.g. 404). Is there a way to check this?
    If you are aware of another way I can achieve this whole thing I would be grateful if you could let me know.
    Thanks very much for your help!

    URLConnection doesn't have a getResponseCode
    method...
    But I found a link
    http://bugs.sun.com/bugdatabase/view_bug.do;:WuuT?bug_
    id=4191207
    that helped me found out that there is another class
    called HttpURLConnection:
    ((HttpURLConnection)conn).getResponseCode( )You should read the API:
    http://java.sun.com/j2se/1.5.0/docs/api/java/net/URL.html#openConnection()
    "If for the URL's protocol (such as HTTP or JAR), there exists a public, specialized URLConnection subclass belonging to one of the following packages or one of their subpackages: java.lang, java.io, java.util, java.net, the connection returned will be of that subclass. For example, for HTTP an HttpURLConnection will be returned,..."

  • How to check the DTP status (i.e in active mode or not) for the Prior days.

    Hi SAP gurus,
    How to check the DTP status whether it was in active mode or inactive mode for the prior days ?

    Hi Aditya,
    Kindly have a look into below links,
    http://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/00dbbfa9-dba2-2d10-bc80-9d6489e4b1c7?QuickLink=index&overridelayout=true
    DTP request Overall status
    Hope this helps.
    Regards,
    Mani

  • Check the order status

    Hi,
    When I do the issue goods to production order,the system massage:Current order status 1000043 does not allow goods withdrawals,Check the order status.
    But how to check? I can't find the wrong.
    regards,
    Zhou.

    Zhou,
    The relesase is getting rejected.
    That's y the status is RELR
    Follow the path in CO02
    Goto-- Logs-- Release.
    Here you will get the reaason for the rejection of the release.
    It might be due to material unavailability.
    You must have done the settings in 'Checking control'.
    Execute T code OPJK.
    Select the combination of the plant, order type & business function 2 & click on details.
    In the next screen against 'Release material' it must be 3. Change it 1 or 2 & save.
    Now try to release the order. It will be released & GI can be done.
    Hope this helps you.
    SmanS

  • Check the system status

    Hi,
    I have a simple question for you..
    How can I check the system status when i save my order...
    The purpose is not save orders whith errors.
    Thanks,
    Hugo.

    Hi Hugo,
    You need not do anything with the status.
    Just create a BADI Implementation for the BADI definition ORDER_SAVE in SE19.
    In the method PREPARE, call the function module CRM_MESSAGES_CHECK_FOR_ERRORS to check for errors in the order. If there are errors in the order then call the function module CRM_MESSAGE_COLLECT to show the additional error message 'Order can't be saved as it contains error' and exit.
    You can also do any additional validation that you want. Save and activate the BADI implementation.
    Now create an order and see if the code written works or not.
    <b>Reward points if it helps.</b>

  • I am set up mac mini and when I test the mail server by sending a mail from administrator to administrator I get the error message 'Diagnostic-Code: X-Postfix; connect to 127.0.0.1[127.0.0.1]:10024: Connection    refused'. Can any one suggest a solution

    I set up mac mini and when I test the mail server by sending a mail from administrator to administrator I get the error message 'Diagnostic-Code: X-Postfix; connect to 127.0.0.1[127.0.0.1]:10024: Connection    refused'. Can any one suggest a solution

    Thanks. Where could I possibly look for a firewall rule. I knowingly did not creat any. My system has internet coming to a Modem which then is connected to a wireless router. I have computers connecting to the router through cable as well as wireless. One of these computers has been our  mailserver using Mercury and Pegasus and that computer has a static IP address. The Mac Mini also has been assigned a different srtatic IP address. I have only set up user account, none of them an email account as I initially expect them to receive only internal mails. Is it necessary that I must set up an email id for each user while setting up the user account. My server id is server.local. So would the email id for local users be [email protected]?

  • Essbase Java Apis- Checking the Load status of Cube

    Hi all,I am using Essbase 7.1 Java Apis.I want to check the Load status of the Cube.I have used the following Api.Cube.getCubeLoadStatus() However there is problem with this Api.If the Cube is not loaded then when I use this Api for the first time, it shows the status as "Not Loaded".However subsequent calls to the same Api shows that the same Cube is "Loaded".Clearly use of this Api results in loading of a Cube which was initilally unloaded.(I belive, in Administrative console right click on Cube -> Stop results in unloading of the Cube)Please answer my following questions :1) Which Api should I use to check the Cube's load status without affecting its current load state.2)I tried using Cube.isActive() Api.However this Api throws an exception for all states of the Cube.3)What is the diffence between a "Loaded" Cube and an "Active" CubeThanks

    1) Which Api should I use to check the Cube's load status without affecting its current load state. <<I don't know the answer to this one.. It seems to me that it may be a bug. You should report this one to Hyperion Tech Support.>>2)I tried using Cube.isActive() Api.However this Api throws an exception for all states of the Cube. <<I haven't tried this one either..>>3)What is the diffence between a "Loaded" Cube and an "Active" Cube <<Finally one I think I can answer.. A loaded cube means, I believe, that the cube has been loaded by the server and is immediately available. An 'active' cube, on the other hand, is the terminology used to specify that a specific connection is connected to, and using, a specific cube. I know several of the VB/C APIs specify that you must set a cube active (on the connection) before you can use the API.Tim TowApplied OLAP, Inc

Maybe you are looking for