Subversion Repositories SmartDukaan

Rev

Rev 8675 | Rev 10298 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 8675 Rev 9703
Line 240... Line 240...
240
 
240
 
241
		//Setting the Subject
241
		//Setting the Subject
242
		msg.setSubject(subject);
242
		msg.setSubject(subject);
243
		return msg;
243
		return msg;
244
	}
244
	}
-
 
245
	
-
 
246
	public void sendSSLMessage(String recipients[], String subject,final String from, final String password,String htmlContent) throws MessagingException {
-
 
247
		try {
-
 
248
			Message msg = prepareMessage(recipients, subject, from, password);
-
 
249
			//Create the multi-part object to hold the text and attachment parts
-
 
250
			Multipart multipart = new MimeMultipart();
-
 
251
			MimeBodyPart htmlPart = new MimeBodyPart();
-
 
252
			htmlPart.setContent(htmlContent, "text/html; charset=utf-8");
-
 
253
			multipart.addBodyPart(htmlPart);
-
 
254
			msg.setContent(multipart);
-
 
255
			Transport.send(msg);
-
 
256
		} catch (Exception e) {
-
 
257
			// If there is any error with normal mail sending, try diving receipients across domains
-
 
258
			if (hasMultipleDomains(recipients)) {
-
 
259
				for (List<String> subReceipients : getReceipientsPerDomain(recipients).values()) {
-
 
260
					sendSSLMessage(subReceipients.toArray(new String[0]), subject, "", from, password, "");
-
 
261
				}
-
 
262
 
-
 
263
				return;
-
 
264
			}
-
 
265
 
-
 
266
			throw new MessagingException(e.getMessage(), e);
-
 
267
		}
-
 
268
	}
-
 
269
 
245
 
270
 
246
	public static void main(String args[]) throws Exception {
271
	public static void main(String args[]) throws Exception {
247
		String[] sendTo = { "mandeep.dhir@shop2020.in", "mandeep.dhir@gmail.com", "mandeepcse07@yahoo.co.in", "anupam.singh@shop2020.in" };
272
		String[] sendTo = { "mandeep.dhir@shop2020.in", "mandeep.dhir@gmail.com", "mandeepcse07@yahoo.co.in", "anupam.singh@shop2020.in" };
248
		String emailSubjectTxt = "Another test from gmail";
273
		String emailSubjectTxt = "Another test from gmail";
249
		String emailMsgTxt = "Test Message Contents";
274
		String emailMsgTxt = "Test Message Contents";