Java tutorial
import java.security.Security; import java.util.Properties; import junit.framework.TestCase; import org.apache.commons.mail.MultiPartEmail; import org.bouncycastle.jce.provider.BouncyCastleProvider; import org.viafirma.util.SendMailUtil; /* * File: TestSendMail.java * * Created on Apr 17, 2008 * * * Copyright 2006-2007 Felix Garcia Borrego (borrego@gmail.com) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ /** * * */ public class TestSendMail extends TestCase { public void testSend() { try { Security.removeProvider(new BouncyCastleProvider().getName()); Security.addProvider(new BouncyCastleProvider()); //log.info("Lista de proveedores disponible:"+Arrays.asList(Security.getProviders())); org.apache.xml.security.Init.init(); Properties configuracion = new Properties(); configuracion.put("HOST_SMTP", "192.168.10.7"); SendMailUtil.init(configuracion); //benito.galan@avansi.com.do MultiPartEmail mail = SendMailUtil.getCurrentInstance().buildMessage("Ejemplo de Firma", "rquintero@viavansi.com", "", "<p>rubén</p> ", "certificadoavansicxa", "avansicxa"); mail.setDebug(true); // Enviamos String id = mail.send(); System.out.println(id); mail.getMimeMessage().writeTo(System.out); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } } }