Mail Not send Properly

Hi i had prepared a java program to send an attachment file it was compiled but when i interpret then it would show the error message as follows
PLEASE HELP ME
javax.mail.MessagingException: Unknown SMTP host: true;
nested exception is:
java.net.UnknownHostException: true
at com.sun.mail.smtp.SMTPTransport.openServer(SMTPTransport.java:1280)
at com.sun.mail.smtp.SMTPTransport.protocolConnect(SMTPTransport.java:37
0)
at javax.mail.Service.connect(Service.java:275)
at javax.mail.Service.connect(Service.java:156)
at javax.mail.Service.connect(Service.java:105)
at javax.mail.Transport.send0(Transport.java:168)
at javax.mail.Transport.send(Transport.java:98)
at sendfile.postFile(sendfile.java:129)
at sendfile.main(sendfile.java:60)
Caused by: java.net.UnknownHostException: true
at java.net.PlainSocketImpl.connect(Unknown Source)
at java.net.SocksSocketImpl.connect(Unknown Source)
at java.net.Socket.connect(Unknown Source)
at java.net.Socket.connect(Unknown Source)
at com.sun.mail.util.SocketFetcher.createSocket(SocketFetcher.java:232)
at com.sun.mail.util.SocketFetcher.getSocket(SocketFetcher.java:189)
at com.sun.mail.smtp.SMTPTransport.openServer(SMTPTransport.java:1250)
... 8 more
java.net.UnknownHostException: true
at java.net.PlainSocketImpl.connect(Unknown Source)
at java.net.SocksSocketImpl.connect(Unknown Source)
at java.net.Socket.connect(Unknown Source)
at java.net.Socket.connect(Unknown Source)
at com.sun.mail.util.SocketFetcher.createSocket(SocketFetcher.java:232)
at com.sun.mail.util.SocketFetcher.getSocket(SocketFetcher.java:189)
at com.sun.mail.smtp.SMTPTransport.openServer(SMTPTransport.java:1250)
at com.sun.mail.smtp.SMTPTransport.protocolConnect(SMTPTransport.java:37
0)
at javax.mail.Service.connect(Service.java:275)
at javax.mail.Service.connect(Service.java:156)
at javax.mail.Service.connect(Service.java:105)
at javax.mail.Transport.send0(Transport.java:168)
at javax.mail.Transport.send(Transport.java:98)
at sendfile.postFile(sendfile.java:129)
at sendfile.main(sendfile.java:60)
aND MY SOURCE CODE IS
import java.util.*;
import java.io.*;
import javax.mail.*;
import javax.mail.internet.*;
import javax.activation.*;
public class SendingFile
static String SMTP_HOST_NAME = "smtp.gmail.com";
static String SMTP_AUTH_USER = "xxxx";
static String emailSubjectTxt = "From xxx S/W";
static String SMTP_AUTH_USER = "xxx";
static String SMTP_AUTH_PWD = "xxxxx";
static String emailFromAddress = "xxxx ";
static StringBuffer sb = new StringBuffer();
static String[] emailList = {"[email protected]", "[email protected]"};
static String filename = "user.htm";
public static void main(String args[]) throws Exception
SendingFile smtpMailSender = new SendingFile();
smtpMailSender.postMail( emailList, emailSubjectTxt, emailFromAddress, filename);
// create some properties and get the default Session
for(int i = 0; i<emailList.length; i++)
System.out.println("Sucessfully Sent mail to All Users"+emailList);
public void postMail( String recipients[ ], String message , String from, String filename) throws MessagingException
boolean debug = false;
Properties props = new Properties();
props.put("mail.smtp.host", SMTP_HOST_NAME);
props.put("mail.smtp.host", "true");
Authenticator auth = new SMTPAuthenticator();
Session session = Session.getDefaultInstance(props, auth);
session.setDebug(debug);
// create a message
MimeMessage msg = new MimeMessage(session);
msg.setFrom(new InternetAddress(from));
InternetAddress[] addressTo = new InternetAddress[recipients.length];
     for (int i = 0; i < recipients.length; i++)
     addressTo[i] = new InternetAddress(recipients[i]);
msg.setRecipients(Message.RecipientType.TO, addressTo);
// msg.setSubject(message);
// create and fill the first message part
MimeBodyPart mbp1 = new MimeBodyPart();
mbp1.setText(message);
// create the second message part
MimeBodyPart mbp2 = new MimeBodyPart();
// attach the file to the message
FileDataSource fds = new FileDataSource(filename);
mbp2.setDataHandler(new DataHandler(fds));
mbp2.setFileName(fds.getName());
// create the Multipart and add its parts to it
Multipart mp = new MimeMultipart();
mp.addBodyPart(mbp1);
mp.addBodyPart(mbp2);
// add the Multipart to the message
msg.setContent(mp);
// set the Date: header
// msg.setSentDate(new Date());
// send the message
Transport.send(msg);
private class SMTPAuthenticator extends javax.mail.Authenticator
     public PasswordAuthentication getPasswordAuthentication()
     String username = SMTP_AUTH_USER;
     String password = SMTP_AUTH_PWD;
     return new PasswordAuthentication(username, password);
Message was edited by:
muthu2007
Message was edited by:
muthu2007

props.put("mail.smtp.host", SMTP_HOST_NAME);
props.put("mail.smtp.host", "true");Remove the second line...
Christian

Similar Messages

  • IMAP gmail - mail not sending properly

    I have my mail app set up with a gmail IMAP account. My outgoing mail is often not able to be sent despite wifi being on. I hit send and an error comes up saying "a copy has been placed in your outbox. The message content could not be sent to the server" or something like that. The problem is intermittent. I've been trying to work out exactly which messages don't work, and i've gotten at least part of the way there. If I am sending a reply to a message and it doesn't send if I get rid of the quote levels and leave just my response it will send. However, very large messages or forwarding attachments generally do not send at all even after repeated attempts.
    So it seems it may be to do with the size of the message trying to be sent, or perhaps the server can't handle the quote levels, but then sometimes these ones get through fine so I don't think it can be this.
    I have spoken to apple. They advised me to delete the account and start again, which I've done but the problem is still persisting. Anyone got any ideas?
    Chris

    I though that gmail was having issues, are you using a wifi connection or 3G?
    Either one, if your using wifi check the SMTP settings for your Internet Service Provider.
    You can usually find it by google. They may have multiple SMTP server settings but try each one.
    Replace the gmail SMTP settings with the ones you find.
    If your using 3G, idk who else is selling iPad now (Verizon, AT&amp;T, Sprint?) try using theres.
    Either way who ever supplying the Internet try swapping them out for SMTP server addresses, ports, or SSL capabilities.
    I hope this works for you as it did for me.
    P.S.
    If you switch between WIFI and 3G specific SMTP servers may have troubles when switching between the two.
    Check if gmail has alternate SMTP server settings other then the ones you may already have selected on your device.
    Anyways good luck!

  • Sharepoint 2013 designer workflow mail not sending

    Hi
    I am doing sharepoint 2013 workflow for mail sending  using designer.
    I am sending mail when new item created in List.
    Here status is completed, but mail not sending the following error comes
    "The e-mail message cannot be sent. Make sure the e-mail has a valid recipient".
    But i have valid email ID.
    If i am sending mail through C# (Visual Webpart), mail sending properly.
    Give me solution, Thanks in advance

    Can you please check the below threads
    http://social.technet.microsoft.com/Forums/sharepoint/en-US/3c76459c-01f5-4d75-be17-ee5b2ce1c1dd/sharepoint-designer-2013-workflow-not-sending-emails?forum=sharepointgeneral
    http://social.technet.microsoft.com/Forums/sharepoint/en-US/caee58c6-3128-4241-92e2-62f1d0bff01f/sharepoint-workflow-not-sending-e-mail?forum=sharepointcustomizationlegacy
    My Blog- http://www.sharepoint-journey.com|
    If a post answers your question, please click Mark As Answeron that post andVote as Helpful

  • Since moving to iCloud my mail not sending attachments any answers?

    Hi
    Since moving to iCloud my mail not sending attachments any answers?

    After the migration I started having problems with all NON Apple things.
    Now, as of July, 6th this is my situation:
    Lion devices and iOS5 devices (MacBook, MacPro, iPhone 4s and iPad I) - fine
    have a look here for info:
    AUTOMATIC SETUP FOR APPLE MAIL ON LION MACS
    http://www.apple.com/icloud/setup/mac.html
    Snow Leopard - set up after some trouble using these instructions:
    OLDER SERVER FOR APPLE MAIL ON PRE OS 10.7 MACS
    http://support.apple.com/kb/HT5330
    Non Apple clients should work with these instructions but I still cannot get MailForge to work:
    SERVERS FOR GENERIC EMAIL CLIENTS
    http://support.apple.com/kb/HT4864
    MOBILE NON APPLE STUFF
    With my HP (Palm) Pre 3 I am still figuring out why every single day they change the servers:
    this however might help you as the Palm is more similar to the BB than the iPhone:
    PALM PRE 3 SETTINGS: I also have updated the password on iCloud, deleted the old iCloud account on the Pre, created a new one. Please note that it now sends using the older server, I do not know for how long.
    INCOMING
    OUTGOING

  • Apple mail not sending via my server hotmail.

    apple mail not sending via my server hotmail.  Please help

    How would you like us to help when you don't provide any details.  We don't have a crystal ball.

  • Out going mail not sending in mavericks

    I've had this problem since upgrading to mavericks, mail not sending and the sntp server showing off line.
    I"VE FIXED IT!!!!
    Guys hope this helps, the ports show default - 25, 465, 585 in edit smtp settings. Check the next box down - use this port and type in 25, I know its in the default list but its sent my mail when using the custom port.
    Hope this helps, I spent all day yesterday on to my server supplier and onto chat with Apple in US but couldnt solve it.
    Best of luck!!

    For the past few weeks, I have been noticing a similar problem: access to 11 email accounts, and three domains, is blocked on occasion. According to my web hosting company, this is happening because some process was attempting to connect via port 585, an insecure IMAP port; and that an automatic firewall rule was invoked to block those attempts. The blocking would last for about one hour after the last attempt was made to connect.
    I'm running Mavericks. If I quit Mail, then restarted one hour later, the problem was resolved. UNTIL Mail attempted to connect to my mail servers, upon which the blocks were triggered again.
    I downloaded Little Snitch. It told me, unsurprisingly at this point, that three email accounts were attempting to use port 585 to connect to their mail server. But I DON'T USE IMAP with those accounts! Why Mail is attempting to connect to a port which I haven't configured it to use is the puzzle.
    The solution for me: tell Little Snitch to deny any access via port 585.

  • HT1338 has anyone else had problems with their mail not loading properly and the multi gestures stopped working on their mac pro after new updates?

    has anyone else had problems with their mail not loading properly and the multi gestures stopped working on their mac pro after new updates?

    Have you tried calling Apple tech support?
    http://www.apple.com/contact/

  • Why does my aol mail not sync properly with the Droid Razr? Never had the problem with blackberry but now I deal with a great deal of spam & duplicating tasks

    Why does my aol mail not sync properly with the Droid Razr? Never had the problem with blackberry but now I deal with a great deal of spam & duplicating tasks

    This may sound stupid, but I'm gonna throw it out there anyway. Is it possible, that if I have enough junk on my desktop it might disrupt the signal? It seems odd, but it kind of looks like my signal is strong and relatively steady now that I've cleaned my desktop. I do tend to get very cluttered. I use a lot of reference images and save text clippings to use later... it just piles up very quickly.
    So, I wonder if all that extra effort my system has to do keeping up with the junk might have something to do with the drop outs?

  • Outgoing mail not sending - ISP has verified correct settings

    The outgoing email on my IMAC is not working - unable to send - my ISP has confirmed the settings are correct - incoming emails working properly.

    Hi Scanners67,
    Thanks for visiting Apple Support Communities.
    It sounds like you're not able to send email from your ISPs mail server on your iMac.
    There could be several causes of the behavior. I would start with the troubleshooting steps in the "Mail Connection Doctor shows one or more red dots in the account Status column" section of this article:
    OS X Mail: Troubleshooting sending and receiving email messages
    This article contains a variety of steps that can help resolve an issue like the one you're seeing.
    All the best,
    Jeremy

  • Mac Mail not sending my yahoo emails

    Since yesterday, my Mac Mail will not send emails out for my Yahoo smtp email address. This has been set up for almost two years and I did not change anything. I am still receiving my email fine! I'm not getting the normal relay error message I sometimes get with other email accounts. It just sits in outgoing for hours!
    Can anyone help me?

    Try opening up a terminal window and telnet to the smtp server's port 25. If that doesn't work, there is probably some firewall issue or you might have mistypyed the name of the smtp server.
    The telnet command would look something like ...
    telnet smtp_server 25
    If you get a response from the SMTP server, check with your ISP's tech support to verify that you are connecting properly.

  • Mail not sending Event to iCal after upgrade

    I did the same as everyone else and upgraded as soon as I saw the message to upgrade mobileme ical. Now when I try to create an event in iCal using a date in an email after clicking on "Add To iCal" the popup just freezes. I've quited and rebooted Mail as well as iCal and no luck.
    Anyone else have this issue? Better yet, did anyone else find out how to fix it?
    With 4 boys I rely on that convenience big time!
    Maria

    The general approach at this time is to ask if you've checked for any problematic fonts (all languages) with Apple's Font Book (look in the Applications folder). Find and remove all duplicates also.
    Start there to be sure all fonts that are in play come out with a clean bill of health.
    Don't hesisate to perform wholesale deletion of old and/or little used fonts - be skeptical of anything that has come from Office 2008, including those related to an Equation Editor installation.
    By all means be sure any 3rd party apps AND plug-ins are Snow Leopard compatible.
    An additional measure is to clear the existing font caches:
    http://www.macworld.com/article/139383/2009/03/fontcacheclear.html
    That said, 10.6.2 release notes have this to say about fonts:
    http://support.apple.com/kb/HT3874
    Fonts fixes provided for:
    • an issue with font spacing
    • an issue in which some Fonts are missing
    • font duplication issues
    • an issue with some PostScript Type 1 fonts not working properly
    Good luck in any case.

  • Mail not sending - this works for me...

    I have what seems to be an increasingly common problem with Mail in SL. Suddenly not sending. I've read all the advice, which is great and helpful, but the problem here is that this is suddenly happening. No change to any settings, ISP has no problem with the port, I can send from a Mac Pro running Leopard. What seems to work (don't ask me why) is shutting down Mail for at least a minute. I know it makes no sense, and it's doubly annoying, because [it appears] that solutions to problems with Macs are getting closer to the old solutions for wintel - shut down, restart and hope. If possible, sacrifice a chicken simultaneously.
    Shame. I was enjoying the Mac experience!

    I don't have any problem sending, and using several different SMTP.
    If this is only with your laptop, I suspect that in moving from place to place and likely using the Default Port list for the SMTP that it is getting switched from time to time between ports in the list, and not finding the right one sometimes.
    If you have a SMTP that will work on, say Port 587 or 465, and never need Port 25, change to Use Custom Port and directly enter the needed port, rather than use the Default list. If, however, your home venue requires Port 25, but moving about requires one of the others, then not a good workaround.
    Ernie

  • Mail not send opened  got lotsof code

    hi , does anyone know?
    mail didnt send then
    saying was not connecting once it  did
    code was going on and on nostop
    so i force quit mail.
    what does this mean?
    Thanks!

    props.put("mail.smtp.host", SMTP_HOST_NAME);
    props.put("mail.smtp.host", "true");Remove the second line...
    Christian

  • Mail not send when subroutine is call in dynamic actions

    Hi Friends,
    I have facing a problem in sending a mail through dynamic actions . In this mail is not send to specific user mail-id.
    Suggest me . What to be exactly done .
    Regards,
    Anish

    First you have to understand what should be done...
    ask your functional consulatant where exactly the Mails need to be retrived For example...
    in infotype 0105 subtype '010'  generally we have email ids avaialable of the employeee....
    may be this helps or not give full specification some one can revert back.
    Regards
    sas

  • Why will mail not send when it will receive?

    Mail receives correspondence on all accounts, but will not send on the grounds that the server forbids retransmission.  However it does work with wegbmail like yahoo and g accessed through safari.  How can I resolve this?

    Did you check the outgoing mail server setting in each account? 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.

Maybe you are looking for