private boolean SendSMTP(mail aMail, String SMTPServer, String ContentType_Charset)
private boolean SendSMTP(mail aMail, String SMTPServer)
	private boolean SendSMTP(mail aMail, String SMTPServer, String ContentType_Charset)	{		final int TCP_PROTOCOL_SMTP = 25;									//SMTP Protocol		String SMTPResult = "";												//Holds the server Result code when an SMTP Command is executed				try		{			//Create a Socket and connect to the SMTP Server			Socket smtpSock = new Socket(SMTPServer, TCP_PROTOCOL_SMTP);						//Create a Buffered Reader for the Socket			BufferedReader in = new BufferedReader(new InputStreamReader(smtpSock.getInputStream()));							//Create an Output Writer for the Socket			PrintWriter out = new PrintWriter(new OutputStreamWriter(smtpSock.getOutputStream()));						//First line sent to us from the SMTP server should be "220 blah blah", 220 indicates okay			SMTPResult = in.readLine();			if(!SMTPResult.substring(0, 3).toString().equals("220"))			{				LOG.error("Error - SMTP Server not ready!");				return(false);			}							//Say "HELO"			out.println("HELO " + InetAddress.getLocalHost().getHostName());			out.flush();							//get "HELLO" response, should be "250 blah blah"			SMTPResult = in.readLine();			if(!SMTPResult.substring(0, 3).toString().equals("250"))			{				LOG.error("Error - SMTP HELO Failed: " + SMTPResult);				return(false);			}						//Send "MAIL FROM:"			//Check format of from address does it include a name as well as the email address?			if(aMail.getFrom().indexOf("<") != -1)			{				//yes, just send the email address				out.println("MAIL FROM: " + aMail.getFrom().substring(aMail.getFrom().indexOf("<") + 1, aMail.getFrom().indexOf(">")));			}			else			{				//no, doesnt include a name so send the email address				out.println("MAIL FROM: " + aMail.getFrom());			}			out.flush();							//Get "MAIL FROM:" response			SMTPResult = in.readLine();			if(!SMTPResult.substring(0, 3).toString().equals("250"))			{				LOG.error("Error - SMTP MAIL FROM failed: " + SMTPResult);				return(false);			}						//RCPT TO should be issued for each to, cc and bcc recipient			Vector allrecipients = new Vector();			allrecipients.addAll(aMail.getTo());			allrecipients.addAll(aMail.getCC());			allrecipients.addAll(aMail.getBCC());							for(int x = 0; x < allrecipients.size(); x++)			{				//Send "RCPT TO:"				//Check format of to address does it include a name as well as the email address?				if(((String)allrecipients.elementAt(x)).indexOf("<") != -1)				{					//yes, just send the email address					out.println("RCPT TO: " + ((String)allrecipients.elementAt(x)).substring(((String)allrecipients.elementAt(x)).indexOf("<") + 1, ((String)allrecipients.elementAt(x)).indexOf(">")));				}				else				{					out.println("RCPT TO: " + ((String)allrecipients.elementAt(x)));				}				out.flush();								//Get "RCPT TO:" response				SMTPResult = in.readLine();				if(!SMTPResult.substring(0, 3).toString().equals("250"))				{					LOG.error("Error - SMTP RCPT TO failed: " + SMTPResult);				}			}									//SEND "DATA" 			out.println("DATA");			out.flush();						//Get "DATA" response, should be "354 blah blah"			SMTPResult = in.readLine();			if(!SMTPResult.substring(0, 3).toString().equals("354"))			{				LOG.error("Error - SMTP DATA failed: " + SMTPResult);				return(false);			}						//Send the Message			WriteMessage(out, aMail, ContentType_Charset);						//Get end message response, should be "250 blah blah"			SMTPResult = in.readLine();			if(!SMTPResult.substring(0, 3).toString().equals("250"))			{				LOG.error("Error - Message not accepted: " + SMTPResult);				return(false);			}		}		catch(IOException e)		{			return(false);		}				//Message Sent Succesfully		LOG.info("send-email() message sent using SMTP " + new Date());		return(true);	}