Results 1 to 2 of 2

Thread: spring-mail-framework authentication problem

  1. #1
    Join Date
    May 2005
    Posts
    13

    Default spring-mail-framework authentication problem

    hi

    when i try to send mails using spring javamail support, i get the following exception:

    Code:
    org.springframework.mail.MailSendException: Could not send mails: 451 4.1.8 To send mail, first check your mail with a valid POP3 account; this prevents unauthorized SPAM relaying.
    
    com.sun.mail.smtp.SMTPSendFailedException: 451 4.1.8 To send mail, first check your mail with a valid POP3 account; this prevents unauthorized SPAM relaying.
    
    	at com.sun.mail.smtp.SMTPTransport.issueSendCommand(SMTPTransport.java:1275)
    	at com.sun.mail.smtp.SMTPTransport.mailFrom(SMTPTransport.java:895)
    	at com.sun.mail.smtp.SMTPTransport.sendMessage(SMTPTransport.java:524)
    	at org.springframework.mail.javamail.JavaMailSenderImpl.doSend(JavaMailSenderImpl.java:382)
    	at org.springframework.mail.javamail.JavaMailSenderImpl.send(JavaMailSenderImpl.java:291)
    	at org.springframework.mail.javamail.JavaMailSenderImpl.send(JavaMailSenderImpl.java:277)
    	at de.carpeventum.gallery.service.GalleryImpl.register(GalleryImpl.java:244)
    	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    	at java.lang.reflect.Method.invoke(Method.java:585)
    	at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:310)
    	at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:155)
    	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:122)
    	at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:57)
    	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:144)
    	at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:174)
    	at $Proxy0.register(Unknown Source)
    	at de.carpeventum.gallery.web.UserFormController.onSubmit(UserFormController.java:30)
    	at org.springframework.web.servlet.mvc.SimpleFormController.processFormSubmission(SimpleFormController.java:248)
    	at org.springframework.web.servlet.mvc.AbstractFormController.handleRequestInternal(AbstractFormController.java:243)
    	at org.springframework.web.servlet.mvc.AbstractController.handleRequest(AbstractController.java:128)
    	at org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter.handle(SimpleControllerHandlerAdapter.java:44)
    	at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:684)
    	at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:625)
    	at org.springframework.web.servlet.FrameworkServlet.serviceWrapper(FrameworkServlet.java:386)
    	at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:355)
    	at javax.servlet.http.HttpServlet.service(HttpServlet.java:709)
    	at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
    	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
    	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
    	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:214)
    	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
    	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
    	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
    	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
    	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
    	at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:825)
    	at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:738)
    	at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:526)
    	at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80)
    	at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
    	at java.lang.Thread.run(Thread.java:595)


    my app-servlet.xml



    Code:
    	<bean id="mailSender" class="org.springframework.mail.javamail.JavaMailSenderImpl">
        	<property name="host"><value>post.strato.de</value></property>
        <property name="username"><value>test@test.com</value></property>
        <property name="password"><value>testtestpassword</value></property>
    	</bean>
    
    	<bean id="mailMessage" class="org.springframework.mail.SimpleMailMessage">
        	<property name="from"><value>chaos@carpeventum.de</value></property>
    	</bean>
    
    	<bean id="gallery" parent="baseTransactionProxy">
    		<property name="target">
    			<bean class="de.carpeventum.gallery.service.GalleryImpl">
    				<property name="categoryDao"><ref bean="categoryDao"/></property>
    				<property name="photoDao"><ref bean="photoDao"/></property>
    				<property name="commentDao"><ref bean="commentDao"/></property>
    				<property name="userDao"><ref bean="userDao"/></property>
    				<property name="mailSender"><ref bean="mailSender"/></property>
    				<property name="mailMessage"><ref bean="mailMessage"/></property>
    				<property name="applicationPath"><value>D&#58;\Eigene Dateien\Java Projects\gallery\WebContent</value></property>
    				<property name="categoryDataDirName"><value>category_data</value></property>
    				<property name="maxWidthThumbnail"><value>98</value></property>	
    				<property name="maxHeightThumbnail"><value>100</value></property>
    			</bean>
    		</property>
    	</bean>
    my buisness-object:

    Code:
    public class GalleryImpl implements Gallery &#123;
    	private CategoryDao categoryDao;
    
    	private PhotoDao photoDao;
    
    	private CommentDao commentDao;
    
    	private UserDao userDao;
    
    	private MailSender mailSender;
    
    	private SimpleMailMessage mailMessage;
    
    
    	/**
    	 * @return Returns the categoryDao.
    	 */
    	public CategoryDao getCategoryDao&#40;&#41; &#123;
    		return categoryDao;
    	&#125;
    
    	/**
    	 * @param categoryDao
    	 *            The categoryDao to set.
    	 */
    	public void setCategoryDao&#40;CategoryDao categoryDao&#41; &#123;
    		this.categoryDao = categoryDao;
    	&#125;
    
    	/**
    	 * @return Returns the commentDao.
    	 */
    	public CommentDao getCommentDao&#40;&#41; &#123;
    		return commentDao;
    	&#125;
    
    	/**
    	 * @param commentDao
    	 *            The commentDao to set.
    	 */
    	public void setCommentDao&#40;CommentDao commentDao&#41; &#123;
    		this.commentDao = commentDao;
    	&#125;
    
    	/**
    	 * @return Returns the photoDao.
    	 */
    	public PhotoDao getPhotoDao&#40;&#41; &#123;
    		return photoDao;
    	&#125;
    
    	/**
    	 * @param photoDao
    	 *            The photoDao to set.
    	 */
    	public void setPhotoDao&#40;PhotoDao photoDao&#41; &#123;
    		this.photoDao = photoDao;
    	&#125;
    
    	/**
    	 * @return Returns the userDao.
    	 */
    	public UserDao getUserDao&#40;&#41; &#123;
    		return userDao;
    	&#125;
    
    	/**
    	 * @param userDao
    	 *            The userDao to set.
    	 */
    	public void setUserDao&#40;UserDao userDao&#41; &#123;
    		this.userDao = userDao;
    	&#125;
    
    	/**
    	 * @return Returns the mailMessage.
    	 */
    	public SimpleMailMessage getMailMessage&#40;&#41; &#123;
    		return mailMessage;
    	&#125;
    
    	/**
    	 * @param mailMessage
    	 *            The mailMessage to set.
    	 */
    	public void setMailMessage&#40;SimpleMailMessage mailMessage&#41; &#123;
    		this.mailMessage = mailMessage;
    	&#125;
    
    	/**
    	 * @return Returns the mailSender.
    	 */
    	public MailSender getMailSender&#40;&#41; &#123;
    		return mailSender;
    	&#125;
    
    	/**
    	 * @param mailSender
    	 *            The mailSender to set.
    	 */
    	public void setMailSender&#40;MailSender mailSender&#41; &#123;
    		this.mailSender = mailSender;
    	&#125;
    
    	&#91;b&#93;public void register&#40;User user&#41; &#123;
    		String password = this.generatePassword&#40;&#41;;
    		user.setPasshash&#40;"" + password.hashCode&#40;&#41;&#41;;
    		SimpleMailMessage message = new SimpleMailMessage&#40;this.mailMessage&#41;;
    		message.setTo&#40;user.getEmail&#40;&#41;&#41;;
    		message.setSubject&#40;"test"&#41;;
    		message.setText&#40;"Your Account&#58;\n\n" + "Username&#58; "
    				+ user.getId&#40;&#41; + "\nPass&#58; " + password&#41;;
    		mailSender.send&#40;message&#41;;
    		userDao.storeUser&#40;user&#41;;
    	&#125;&#91;/b&#93;
    &#125;
    need some help thx

  2. #2
    Join Date
    Aug 2004
    Location
    Auburn, AL, USA.
    Posts
    106

    Default

    I believe the problem is "on" your mail server. While there is an extension to SMTP that supports authentication, many mail server's don't have any means to do authentication when sending email. The work around that many servers offer is to:
    • User checks email via POP, which supports authentication.
    • Server adds user's IP to an 'allowed' list (which typically expires every 30 minutes).
    • User (IP) can now send email via SMTP.

    In such a setup there is usually a list of non-expiring IPs which are allowed to send email. You will need to talk to whom ever is responsible to administering your email server and see what you can do to get setup to send email.

Similar Threads

  1. Spring MVC Web Framework versus Struts
    By biguniverse in forum Web Flow
    Replies: 27
    Last Post: Aug 29th, 2012, 03:57 AM
  2. Spring-based Mail Template Framework
    By eisenb in forum Architecture
    Replies: 3
    Last Post: Dec 2nd, 2010, 07:24 AM
  3. Replies: 2
    Last Post: Oct 13th, 2005, 02:47 PM
  4. Replies: 14
    Last Post: Feb 21st, 2005, 05:41 PM
  5. Replies: 8
    Last Post: Dec 7th, 2004, 06:13 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •