Java mail api - sending mails to gmail account

Hello
I am using java mail api to send mails.when i send mails to gmail from ids which are not in gmail friends list, most of the mails are going to spam.Ofcourse, some of them go to inbox.I tried in lot of ways to analyse the problem.But nothing could help. Can anyone plzz tell me how to avoid mails going to spam in gmail, using java mail api?
Thank you in advance,
Regards,
Aradhana
Message was edited by:
Aradhana

am using the below code.
Properties props = System.getProperties();
//          Setup mail server
          props.put("mail.smtp.host", smtpHost);
          props.put("mail.smtp.port","25");
          props.put("mail.smtp.auth", isAuth);
     Authenticator auth = new UserAuthenticator();
//          Get session
          Session s = Session.getDefaultInstance(props,auth);
//          Define message
          Message m = new MimeMessage(s);
//          setting message attributes
          try {
               m.setRecipient(Message.RecipientType.TO, new InternetAddress(to));
               InternetAddress f_addr=new InternetAddress(from);
               f_addr.setPersonal(personalName);
               m.setFrom(f_addr);               
               m.setSubject(subject);
               m.setSentDate(new Date());
               m.setContent(msg,"text/plain");
               m.saveChanges();
//               send message
               Transport.send(m);
Message was edited by:
Aradhana

Similar Messages

  • I have 4 email accounts in apple Mail.  My mail is sending from the wrong account.  even on "reply" it sends from a different account.  I have 3 gmail accounts and one exchange server account. I choose which account to send from and it still sends from a

    I have 4 email accounts in apple Mail.  My mail is sending from the wrong account.  even on "reply" it sends from a different account.  I have 3 gmail accounts and one exchange server account. I choose which account to send from and it still sends from the same gmail account.  Help.

    I HAD two accounts because of this problem.  I completely removed the problem account from the Apple Mail client.  Guess what is happening??  That's right - Mail is still sending from the other account that no longer exists on my computer, and I have absolutely no idea how this is happening.  This is incredibly frustrating.  When a recipient chooses to reply to my message, quite often I won't get it now because it is going to the other account that has now been deleted from my system.  COME ON APPLE!!! WHAT'S THE DEAL WITH THIS???

  • SSRS Subscription LastStatus "Failure sending mail: Failure sending mail."

    SSRS 2012, SQL 2012 SP2. 
    We have about 50 different daily subscriptions that go out.  In the last month or so, probably over 30% of SSRS subscriptions are getting this error and no e-mail is sent.  I have tested out the reports with the parameters and the reports run just
    fine on demand for both the user and myself.  I'll change the subscription forward for testing, and it will intermittently work or fail even when no traffic is hitting our database so I dont think it's a matter of performance. 
    I see nothing in the error logs, and I see nothing in the logtable 2, or 3 in ssrs as suggested by a few MSDB sites.
    The only spot I can even see this error, is when viewing the subscription. I have done LOTS of searching, and most people get a helpful error after "Failure sending mail" where as I only get 'Failure sending mail: Failure sending mail"

    Hi,
    Does your network is always available? Your scenario is so strange. Please check if you have missed something according to this article:
    https://msdn.microsoft.com/en-us/library/ms159155.aspx.

  • After hotmail come up on my screen I am not able to open mail or send mail?

    After hotmail comes up on my screen I cannot open mail or send mail. I can send mail on google?

    I downloaded installed firefox 9 even restarted my computer but still not able to open or send mail using hotmail. Also, when i open WGT.com to play golf I also cannot go to the play game screen.
    any more suggestions?
    Pat

  • Why is the "From:" field being changed in Mac Mail.  I have multiple gmail accounts setup and it seems to change the "FROM" field even though I've selected which account to use to send the email.

    So
    I've got multiple gmail accounts setup in Mac Mail.
    Somtimes when I send or forward emails, it uses the wrong FROM field even though I'm declaring
    specifically which account to use.
    This becomes apparent when the person replies to my message and it goes to the wrong account

    Check you accounts in Mail and make sure each account has the correct outgoing server address. Check the box to use only that server.
    Second, go to the gmail website and in settings under the account tab, make sure you have the correct settings for replying to messages.

  • Mail sending from 2 gmail accounts at the same time

    I currently have 2 gmail accounts, one is a Personal account that I use 90% of the time and the other is a Family account. I have them set up to sync through Apple Mail. Since upgrading to Mavericks, whenever I send an email from my Personal account, it appears that it is sending from both accounts even though I only selected to send from my Personal account. The most frustrating part is that the recepients show that it is coming from my Family account. Therefore, when they reply to my original email, the reply comes to my Family account. Does anyone else experience this or have a solution?
    Thanks

    Think I solved my own problem. It seems I just needed to delete both of my gmail accounts from Mail, restart computer, and re-add the accounts. Seems to be working now.

  • HT201320 on my iPad3, i have my company email address and my gmail email account and yahoo email account.  i send out email using my company's email account, but the recipient recieves mail as the From: my gmail account.  why is this happening?

    on my ipad3, i have a company email account, gmail account, and a yahoo account. my issue is that when using my company email account (making sure that my company email account is on the From: field), the recepient on the over end receives it with my google email account on the From:.  and so when they reply, it goes to my gmail account.
    Please note that my "default email" is yahoo.com on the ipad's settings - > mail.
    i do not have any forwarding and this only happens on my ipad.
    Advice is appreciated. Thank you

    ios devices can only send emails from the default sending email you setup that in the settings

  • Problem sending attachements with gmail account on mail

    Hello:
    I have a lot of problems sending attachments with my gmail account using mail.
    1. Attachments are not big.
    2. I don't have the same problem with other non gmail accounts.
    3. When ever I have this problem I go to gamil.com and I am able to send the attachment with no problem.
    Any suggestions?
    Thanks

    No idea ?
    Nemrod

  • Mail won t send emails with gmail account.

    Mail app was working perfectly and suddenly it stopped working
    All i have configured is my gmail account with IMAP, it receives the mails perfectly but i cant get any mail to leave my outbox. I simply get the timeout error with the try again or edit settings message.
    I rechecked and recreated the outgoing mail server with the settings from google, and it still happens.
    I tried rebuilding the outbox as i read on these forums that it might help, but it didnt.
    What else can I do?
    thank you
    Charles .

    Hi.
    You could try moving the preference file to the trash.
    The file is called com.apple.mail.plist
    and can be found in the following folder: username -> library -> preferences

  • Mail app not connecting to gmail account

    Hi
    So I have 2 gmail accounts where our company domain uses gmail for its email service. Mail was working fine on both the accounts till last week.
    I had configured both the gmail accounts very easily by just selecting Google on the Mail App on my Macbook Air 7 months back. I just added my email id and my password and the Mail App automatically configured both my accounts.
    Last week one of the gmail accounts stopped updating on the Mail app on the Macbook. I was recieving mails on my iPad and iPhone so I knew there was something wrong. The second gmail account was working just fine. I tried various things but that account refused to work. So I deleted that account and tried adding that account back. I could not add that gmail account this time round and kept giving me an invalid username password error or some account not valid error. I go to the online version of Gmail and login with exactly the same information.
    Then to probe more I delete the working gmail account and try to add it again. That account also does not seem to be adding now. Same error as the first account. So now I cannot access both my gmail accounts on the mail client.
    I just realized that I updated to OSX Mavericks 10.9.2 on 28th Feb and am pretty sure that all this has happened immediately after that.
    Anybody else with similar issues? Any ideas on what I should be doing?
    Cheers
    Ankur

    Hi there ankz74,
    You may find the troubleshooting steps in the article below helpful.
    OS X Mail: Troubleshooting sending and receiving email messages
    http://support.apple.com/kb/ts3276
    -Griff W. 

  • HT1430 I cannot get mail or send mail on my iPad message says username or password for imap.gmail is incorrect

    I cannot get mail or send email on my I pad message says username or password for imap.gmail is incorrect

    Be sure you use Google's settings from:
    https://support.google.com/mail/troubleshooter/1668960?hl=en&ref_topic=1669040#t s=1665018
    The key is to be sure you have enabled IMAP on your GMAIL account. Follow the instrunctions on that link. Then be sure to check the Advanced settings from:
    https://support.google.com/mail/answer/78892?hl=en

  • Mail.app sycs with one Gmail account, won't with another

    I've searched throughout the forum and couldn't find anything (although a ton of issues with Mail/Gmail exist).
    Today is the first time I've had an issue with Gmail connecting to Mail.app, however, I have two Gmail accounts, yet my main one will not connect. Here's the error message:
    "+Logging in to the Gmail IMAP server “imap.gmail.com” failed. Make sure the user name and password you entered are correct, then click Continue. If the information isn’t correct, you cannot receive messages+."
    I check my login/password, and it's correct. I can login to Gmail using Firfox and Chrome. My secondary account can receive and send in Mail.app, but nothing in the primary.
    Anyone have an idea?

    I just downloaded Thunderbird and tried to setup my primary Gmail account, and TB has issues logging in, saying the password is invalid, yet it's the same password that I use when I login in a browser, whatever the browser may be. Here's the setup window with the error, and anything else that may be relevant (I have absolutely no knowledge of mail anything; POP, IMAP, all that jazz is pure Latin to me):
    http://img.photobucket.com/albums/v235/pacokorn77/thunderbirderrormessage.png
    Sorry for the link, but I'm not familiar with the forum code here to embed an image (if it's at all possible).
    My Mail app on my iPhone works just fine, sending and receiving, but any desktop client I use kicks back a login issue, so it looks to be on Google's end, but I can't be certain.

  • SENT MAIL COMES IN INBOX OF GMAIL ACCOUNT

    i'm using gmail pop account.
    whenever i send mail from this account i'm getting that mail in my inbox also.
    i've tried to contact google about this problem but they told me that ask your email client developer about this problem!!!!
    Please help me to get rid of this problem....

    See if this article helps.
    https://support.google.com/mail/answer/78892?hl=en&ref_topic=3397500

  • Mail is sending email from wrong account.

    Every time I send or reply to an email it sends from my wifes account.  If people reply to it, it goes back to her account.  when I compose a new email I use the drop down menu that says from: *******@me.com, I make sure its from my account and I send it.  When it gets to the person its says its from my wife.  I have look in the preferences and it is using selected account to send from. I have tried to force it to only send from my account but it always sends from my wifes account.  Any Ideas?

    bgasso wrote:
    Where is the "Reply to" in Mail preferences?
    Not in Preferences. That usually works for a message-by-message basis.
    With a message composition window open in Apple Mail make the following menu selection:
    View > Reply-To Address Field.
    If it's blank, fine.
    It is possible to make it permanent via Terminal, someone would have had to do it at some stage; just wanted to ensure it was not fixed. 
    Do check the SMTP servers set for each account.

  • Mac mail keeps sending emails from different accounts even though it says correct email in "sent" folder. Recipients reply and it goes to different email address. So confusing.

    mac mail keeps sending emails from my different accounts even though it says correct email in "sent" folder and correct email account was highlighted. Recipients reply and it goes to different email address. So confusing and annoying.

    Hi Mike,
    I had the same issue and managed to solve it.
    Go into Mail>Preferences>Accounts
    Then in the account information tab, at the bottom should be outgoing mail server (SMTP) and click the drop down box
    Mine had a few different servers in it so i went into edit SMPT server list. Click advanced and it will tell you which ones are going from which email address.
    Delete the ones you dont want, and it should work or instead of deleting click use only this server, i imagine that will work to
    Hope This Helps
    George

Maybe you are looking for