# E-Mails vom lokalen PC verschicken (möglich?)



## gast (6. Apr 2007)

Hi,
ich habe so ein Buch (J2EE Codebook), da wird beschrieben wie man mit Jsp und java eine E-Mail versenden kann.
Jetzt bin ich Superanfänger und bekomme eine Fehlermeldung. 

Außerdem teste ich das ganze auf meinem Lokalem PC zuhause und habe keinen Mail Server wenn man denn überhaupt einen braucht und genau das wäre meine frage gewesen. 

Hat jemand vielleicht eine Anleitung (möglichst auf Deutsch) wie man so was vom Lokalen PC aus machen kann oder brauche ich überhaupt einen Mail Server?


Zur Info, wenn ich die SendMail() methode einfüge dann bekomme ich die Fehlermeldung.

hier mein mailBean

```
package com.myeclipse.mail;

import java.util.Properties;

import javax.mail.Message;
import javax.mail.MessagingException;
import javax.mail.Session;
import javax.mail.Transport;
import javax.mail.internet.InternetAddress;
import javax.mail.internet.MimeMessage;

public class SendMail {
		
	String mailText;
	String mailSubject;
	String mailAdress;
	
	public String sendMail(){
		
		try {
		
			//Server-Namen in der Properties erfassen
			Properties settings = new Properties(); //in welcher Properties????
			settings.put("java.mail.host", "...");//ich denke mal hier müsste der Mailserver angegeben werden!
			
			//Mail-Session erzeugen
			Session session = javax.mail.Session.getDefaultInstance(settings);
			
			//Nachricht-Erzeugen
			Message message = new MimeMessage(session);
		
			//Absender
			message.setFrom(new InternetAddress("e14445@gmx.de"));
		
			//Empfänger
			message.setRecipient(Message.RecipientType.TO, new InternetAddress("e3200@gmx.de"));
		
			//Betreff
			message.setSubject("Test der JavaMail");
		
			//Nachrichtentext
			message.setText("Dieser Text steht in der Mail");
		
			//Versenden
			Transport.send(message);
		
		
		
			} catch (MessagingException e) 
				{
					// TODO: handle exception
					e.printStackTrace();
				}
			
			return "access";
		}

	
	
	public String getMailAdress() {
		return mailAdress;
	}
	public void setMailAdress(String mailAdress) {
		this.mailAdress = mailAdress;
	}
	public String getMailSubject() {
		return mailSubject;
	}
	public void setMailSubject(String mailSubject) {
		this.mailSubject = mailSubject;
	}
	public String getMailText() {
		return mailText;
	}
	public void setMailText(String mailText) {
		this.mailText = mailText;
	}
	
	
	
}
```
Hier die Fehlermeldung


```
type Exception report

message

description The server encountered an internal error () that prevented it from fulfilling this request.

exception

javax.servlet.ServletException: Cannot get value for expression '#{mailBean.mailText}'
	javax.faces.webapp.FacesServlet.service(FacesServlet.java:121)
	org.apache.myfaces.component.html.util.ExtensionsFilter.doFilter(ExtensionsFilter.java:122)

root cause

javax.faces.FacesException: Cannot get value for expression '#{mailBean.mailText}'
	org.apache.myfaces.context.servlet.ServletExternalContextImpl.dispatch(ServletExternalContextImpl.java:421)
	org.apache.myfaces.application.jsp.JspTilesViewHandlerImpl.dispatch(JspTilesViewHandlerImpl.java:233)
	org.apache.myfaces.application.jsp.JspTilesViewHandlerImpl.renderView(JspTilesViewHandlerImpl.java:219)
	org.apache.myfaces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:352)
	javax.faces.webapp.FacesServlet.service(FacesServlet.java:107)
	org.apache.myfaces.component.html.util.ExtensionsFilter.doFilter(ExtensionsFilter.java:122)

root cause

org.apache.jasper.JasperException: Cannot get value for expression '#{mailBean.mailText}'
	org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:476)
	org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:389)
	org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:315)
	org.apache.jasper.servlet.JspServlet.service(JspServlet.java:265)
	javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
	org.apache.myfaces.context.servlet.ServletExternalContextImpl.dispatch(ServletExternalContextImpl.java:415)
	org.apache.myfaces.application.jsp.JspTilesViewHandlerImpl.dispatch(JspTilesViewHandlerImpl.java:233)
	org.apache.myfaces.application.jsp.JspTilesViewHandlerImpl.renderView(JspTilesViewHandlerImpl.java:219)
	org.apache.myfaces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:352)
	javax.faces.webapp.FacesServlet.service(FacesServlet.java:107)
	org.apache.myfaces.component.html.util.ExtensionsFilter.doFilter(ExtensionsFilter.java:122)

root cause

javax.faces.el.EvaluationException: Cannot get value for expression '#{mailBean.mailText}'
	org.apache.myfaces.el.ValueBindingImpl.getValue(ValueBindingImpl.java:397)
	javax.faces.component.UIOutput.getValue(UIOutput.java:75)
	org.apache.myfaces.renderkit.RendererUtils.getStringValue(RendererUtils.java:225)
	org.apache.myfaces.renderkit.html.HtmlTextRendererBase.renderInput(HtmlTextRendererBase.java:131)
	org.apache.myfaces.renderkit.html.HtmlTextRendererBase.encodeEnd(HtmlTextRendererBase.java:49)
	javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:331)
	javax.faces.webapp.UIComponentTag.encodeEnd(UIComponentTag.java:349)
	javax.faces.webapp.UIComponentTag.doEndTag(UIComponentTag.java:253)
	org.apache.jsp.pages.mail_jsp._jspx_meth_h_005finputText_005f0(mail_jsp.java:215)
	org.apache.jsp.pages.mail_jsp._jspx_meth_h_005fform_005f0(mail_jsp.java:166)
	org.apache.jsp.pages.mail_jsp._jspx_meth_f_005fview_005f0(mail_jsp.java:129)
	org.apache.jsp.pages.mail_jsp._jspService(mail_jsp.java:76)
	org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:98)
	javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
	org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:328)
	org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:315)
	org.apache.jasper.servlet.JspServlet.service(JspServlet.java:265)
	javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
	org.apache.myfaces.context.servlet.ServletExternalContextImpl.dispatch(ServletExternalContextImpl.java:415)
	org.apache.myfaces.application.jsp.JspTilesViewHandlerImpl.dispatch(JspTilesViewHandlerImpl.java:233)
	org.apache.myfaces.application.jsp.JspTilesViewHandlerImpl.renderView(JspTilesViewHandlerImpl.java:219)
	org.apache.myfaces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:352)
	javax.faces.webapp.FacesServlet.service(FacesServlet.java:107)
	org.apache.myfaces.component.html.util.ExtensionsFilter.doFilter(ExtensionsFilter.java:122)

root cause

javax.faces.FacesException: java.lang.NoClassDefFoundError: javax/mail/MessagingException
	org.apache.myfaces.util.ClassUtils.newInstance(ClassUtils.java:279)
	org.apache.myfaces.util.ClassUtils.newInstance(ClassUtils.java:265)
	org.apache.myfaces.config.ManagedBeanBuilder.buildManagedBean(ManagedBeanBuilder.java:49)
	org.apache.myfaces.el.VariableResolverImpl.resolveVariable(VariableResolverImpl.java:311)
	org.apache.myfaces.el.ValueBindingImpl$ELVariableResolver.resolveVariable(ValueBindingImpl.java:569)
	org.apache.commons.el.NamedValue.evaluate(NamedValue.java:124)
	org.apache.commons.el.ComplexValue.evaluate(ComplexValue.java:140)
	org.apache.myfaces.el.ValueBindingImpl.getValue(ValueBindingImpl.java:378)
	javax.faces.component.UIOutput.getValue(UIOutput.java:75)
	org.apache.myfaces.renderkit.RendererUtils.getStringValue(RendererUtils.java:225)
	org.apache.myfaces.renderkit.html.HtmlTextRendererBase.renderInput(HtmlTextRendererBase.java:131)
	org.apache.myfaces.renderkit.html.HtmlTextRendererBase.encodeEnd(HtmlTextRendererBase.java:49)
	javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:331)
	javax.faces.webapp.UIComponentTag.encodeEnd(UIComponentTag.java:349)
	javax.faces.webapp.UIComponentTag.doEndTag(UIComponentTag.java:253)
	org.apache.jsp.pages.mail_jsp._jspx_meth_h_005finputText_005f0(mail_jsp.java:215)
	org.apache.jsp.pages.mail_jsp._jspx_meth_h_005fform_005f0(mail_jsp.java:166)
	org.apache.jsp.pages.mail_jsp._jspx_meth_f_005fview_005f0(mail_jsp.java:129)
	org.apache.jsp.pages.mail_jsp._jspService(mail_jsp.java:76)
	org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:98)
	javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
	org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:328)
	org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:315)
	org.apache.jasper.servlet.JspServlet.service(JspServlet.java:265)
	javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
	org.apache.myfaces.context.servlet.ServletExternalContextImpl.dispatch(ServletExternalContextImpl.java:415)
	org.apache.myfaces.application.jsp.JspTilesViewHandlerImpl.dispatch(JspTilesViewHandlerImpl.java:233)
	org.apache.myfaces.application.jsp.JspTilesViewHandlerImpl.renderView(JspTilesViewHandlerImpl.java:219)
	org.apache.myfaces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:352)
	javax.faces.webapp.FacesServlet.service(FacesServlet.java:107)
	org.apache.myfaces.component.html.util.ExtensionsFilter.doFilter(ExtensionsFilter.java:122)

root cause

java.lang.NoClassDefFoundError: javax/mail/MessagingException
	java.lang.Class.getDeclaredConstructors0(Native Method)
	java.lang.Class.privateGetDeclaredConstructors(Unknown Source)
	java.lang.Class.getConstructor0(Unknown Source)
	java.lang.Class.newInstance0(Unknown Source)
	java.lang.Class.newInstance(Unknown Source)
	org.apache.myfaces.util.ClassUtils.newInstance(ClassUtils.java:274)
	org.apache.myfaces.util.ClassUtils.newInstance(ClassUtils.java:265)
	org.apache.myfaces.config.ManagedBeanBuilder.buildManagedBean(ManagedBeanBuilder.java:49)
	org.apache.myfaces.el.VariableResolverImpl.resolveVariable(VariableResolverImpl.java:311)
	org.apache.myfaces.el.ValueBindingImpl$ELVariableResolver.resolveVariable(ValueBindingImpl.java:569)
	org.apache.commons.el.NamedValue.evaluate(NamedValue.java:124)
	org.apache.commons.el.ComplexValue.evaluate(ComplexValue.java:140)
	org.apache.myfaces.el.ValueBindingImpl.getValue(ValueBindingImpl.java:378)
	javax.faces.component.UIOutput.getValue(UIOutput.java:75)
	org.apache.myfaces.renderkit.RendererUtils.getStringValue(RendererUtils.java:225)
	org.apache.myfaces.renderkit.html.HtmlTextRendererBase.renderInput(HtmlTextRendererBase.java:131)
	org.apache.myfaces.renderkit.html.HtmlTextRendererBase.encodeEnd(HtmlTextRendererBase.java:49)
	javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:331)
	javax.faces.webapp.UIComponentTag.encodeEnd(UIComponentTag.java:349)
	javax.faces.webapp.UIComponentTag.doEndTag(UIComponentTag.java:253)
	org.apache.jsp.pages.mail_jsp._jspx_meth_h_005finputText_005f0(mail_jsp.java:215)
	org.apache.jsp.pages.mail_jsp._jspx_meth_h_005fform_005f0(mail_jsp.java:166)
	org.apache.jsp.pages.mail_jsp._jspx_meth_f_005fview_005f0(mail_jsp.java:129)
	org.apache.jsp.pages.mail_jsp._jspService(mail_jsp.java:76)
	org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:98)
	javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
	org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:328)
	org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:315)
	org.apache.jasper.servlet.JspServlet.service(JspServlet.java:265)
	javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
	org.apache.myfaces.context.servlet.ServletExternalContextImpl.dispatch(ServletExternalContextImpl.java:415)
	org.apache.myfaces.application.jsp.JspTilesViewHandlerImpl.dispatch(JspTilesViewHandlerImpl.java:233)
	org.apache.myfaces.application.jsp.JspTilesViewHandlerImpl.renderView(JspTilesViewHandlerImpl.java:219)
	org.apache.myfaces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:352)
	javax.faces.webapp.FacesServlet.service(FacesServlet.java:107)
	org.apache.myfaces.component.html.util.ExtensionsFilter.doFilter(ExtensionsFilter.java:122)

note The full stack trace of the root cause is available in the Apache Tomcat/5.5.23 logs.
```


Eclipse meldet folgendes:

```
06.04.2007 19:02:14 org.apache.myfaces.util.ClassUtils newInstance
SCHWERWIEGEND: Class : com.myeclipse.mail.SendMail not found.
java.lang.NoClassDefFoundError: javax/mail/MessagingException
	at java.lang.Class.getDeclaredConstructors0(Native Method)
	at java.lang.Class.privateGetDeclaredConstructors(Unknown Source)
	at java.lang.Class.getConstructor0(Unknown Source)
	at java.lang.Class.newInstance0(Unknown Source)
	at java.lang.Class.newInstance(Unknown Source)
	at org.apache.myfaces.util.ClassUtils.newInstance(ClassUtils.java:274)
	at org.apache.myfaces.util.ClassUtils.newInstance(ClassUtils.java:265)
	at org.apache.myfaces.config.ManagedBeanBuilder.buildManagedBean(ManagedBeanBuilder.java:49)
	at org.apache.myfaces.el.VariableResolverImpl.resolveVariable(VariableResolverImpl.java:311)
	at org.apache.myfaces.el.ValueBindingImpl$ELVariableResolver.resolveVariable(ValueBindingImpl.java:569)
	at org.apache.commons.el.NamedValue.evaluate(NamedValue.java:124)
	at org.apache.commons.el.ComplexValue.evaluate(ComplexValue.java:140)
	at org.apache.myfaces.el.ValueBindingImpl.getValue(ValueBindingImpl.java:378)
	at javax.faces.component.UIOutput.getValue(UIOutput.java:75)
	at org.apache.myfaces.renderkit.RendererUtils.getStringValue(RendererUtils.java:225)
	at org.apache.myfaces.renderkit.html.HtmlTextRendererBase.renderInput(HtmlTextRendererBase.java:131)
	at org.apache.myfaces.renderkit.html.HtmlTextRendererBase.encodeEnd(HtmlTextRendererBase.java:49)
	at javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:331)
	at javax.faces.webapp.UIComponentTag.encodeEnd(UIComponentTag.java:349)
	at javax.faces.webapp.UIComponentTag.doEndTag(UIComponentTag.java:253)
	at org.apache.jsp.pages.mail_jsp._jspx_meth_h_005finputText_005f0(mail_jsp.java:215)
	at org.apache.jsp.pages.mail_jsp._jspx_meth_h_005fform_005f0(mail_jsp.java:166)
	at org.apache.jsp.pages.mail_jsp._jspx_meth_f_005fview_005f0(mail_jsp.java:129)
	at org.apache.jsp.pages.mail_jsp._jspService(mail_jsp.java:76)
	at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:98)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
	at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:328)
	at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:315)
	at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:265)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:269)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188)
	at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:691)
	at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:469)
	at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:403)
	at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:301)
	at org.apache.myfaces.context.servlet.ServletExternalContextImpl.dispatch(ServletExternalContextImpl.java:415)
	at org.apache.myfaces.application.jsp.JspTilesViewHandlerImpl.dispatch(JspTilesViewHandlerImpl.java:233)
	at org.apache.myfaces.application.jsp.JspTilesViewHandlerImpl.renderView(JspTilesViewHandlerImpl.java:219)
	at org.apache.myfaces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:352)
	at javax.faces.webapp.FacesServlet.service(FacesServlet.java:107)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:269)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188)
	at org.apache.myfaces.component.html.util.ExtensionsFilter.doFilter(ExtensionsFilter.java:122)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:215)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188)
	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:210)
	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:174)
	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:117)
	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:108)
	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:151)
	at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:870)
	at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:665)
	at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:528)
	at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:81)
	at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:685)
	at java.lang.Thread.run(Unknown Source)....
```


----------



## DP (7. Apr 2007)

hier im forum sind genug beispiele. 

zum versenden solltest du entweder eine statische ip besitzen oder deine mails über einen provider via smtp versenden, damit diese auch ankommen.


----------



## Guest (7. Apr 2007)

Was hat das jetzt mit meiner Frage zu tun? 

Ohne frech zu werden, dann zeig mit doch mal einen Thread in dem das gleiche Problem besprochen wird! 
Die Frage hätte ich nicht gestellt wenn ich diese Antwort nicht schon in einem anderen Thread gefunden hätte schon gefunden hätte.

Da binn ich mal gespannt.


----------



## Jockel (7. Apr 2007)

http://www.java-forum.org/de/viewtopic.php?t=36532&highlight=javamail


----------



## DP (8. Apr 2007)

Anonymous hat gesagt.:
			
		

> Was hat das jetzt mit meiner Frage zu tun?



dir haben se das hirn gefeilt:



			
				Anonymous hat gesagt.:
			
		

> ...keinen Mail Server wenn man denn überhaupt einen braucht und genau das wäre meine frage gewesen...
> ...oder brauche ich überhaupt einen Mail Server?


----------

