package de.website.Bean;

import org.apache.commons.mail.*;

import javax.faces.bean.ManagedBean;
import javax.faces.bean.RequestScoped;

/**
 * Created by Tobi on 29.02.2016.
 */
@ManagedBean(name="sendMail")
@RequestScoped
public class sendBean {
    
    final static Logger logger = Logger.getLogger(sendBean.class);

    public void mailSend(String name, String email, String subject, String text){
        
        String authuser = "...@gmail.com";
        String authpwd = "xxxx";

        Email simMail = new SimpleEmail();
        simMail.setHostName("smtp.googlemail.com");
        simMail.setSmtpPort(465);
        simMail.setAuthenticator(new DefaultAuthenticator(authuser, authpwd));
        simMail.setSSLOnConnect(true);

        try {
            simMail.setFrom(email);
            simMail.setSubject(subject);
            simMail.setMsg(text);
            //email.addTo("foo@bar.com");
            simMail.send();

        } catch (EmailException e){
            
            logger.error("Fehler beim senden der E-Mail: ", e);

        }
    }
}

@@ -483,16 +483,47 @@
 xxxx%22;%0A%0A
+        try %7B%0A            %0A    
         
@@ -557,32 +557,36 @@
 mail();%0A        
+    
 simMail.setHostN
@@ -605,32 +605,36 @@
 oglemail.com%22);%0A
+    
         simMail.
@@ -651,32 +651,36 @@
 t(465);%0A        
+    
 simMail.setAuthe
@@ -734,16 +734,20 @@
 hpwd));%0A
+    
         
@@ -776,31 +776,16 @@
 t(true);
-%0A%0A        try %7B
 %0A       
@@ -1000,32 +1000,32 @@
 )%7B%0A            %0A
-
             logg
@@ -1069,24 +1069,150 @@
 il: %22, e);%0A%0A
+        %7D%0A        %0A    %7D catch (Exception ex)%7B%0A            %0A            logger.error(%22Fehler beim senden der E-Mail: %22, ex);%0A%0A
         %7D%0A  

Update sendBean.java