Announcement Announcement Module
Collapse
No announcement yet.
Mail - example provided by spring Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Mail - example provided by spring

    Hi - I am using the example provided by the spring for sending mails.
    There is no exception but mail is not been forwarded to the destination.
    Here are the statements that it is printing on the console.....

    Can you let me know, do i need to do more than what was mentioned in the example

    CONSOLE LOGGERS

    Creating instance of bean 'mailSender' with merged definition [Root bean: class [org.springframework.mail.javamail.JavaMailSenderIm pl]; scope=singleton; abstract=false; lazyInit=false; autowireCandidate=true; autowireMode=0; dependencyCheck=0; factoryBeanName=null; factoryMethodName=null; initMethodName=null; destroyMethodName=null; defined in file [D:\cts\GTO\New Concept\workspace\SpringQuartz\exampleContext.xml]]
    Eagerly caching bean 'mailSender' to allow for resolving potential circular references
    Creating shared instance of singleton bean 'templateMessage'
    Creating instance of bean 'templateMessage' with merged definition [Root bean: class [org.springframework.mail.SimpleMailMessage]; scope=singleton; abstract=false; lazyInit=false; autowireCandidate=true; autowireMode=0; dependencyCheck=0; factoryBeanName=null; factoryMethodName=null; initMethodName=null; destroyMethodName=null; defined in file [D:\cts\GTO\New Concept\workspace\SpringQuartz\exampleContext.xml]]
    Eagerly caching bean 'templateMessage' to allow for resolving potential circular references
    Creating shared instance of singleton bean 'orderManager'
    Creating instance of bean 'orderManager' with merged definition [Root bean: class [com.spring.test.mail.SimpleOrderManager]; scope=singleton; abstract=false; lazyInit=false; autowireCandidate=true; autowireMode=0; dependencyCheck=0; factoryBeanName=null; factoryMethodName=null; initMethodName=null; destroyMethodName=null; defined in file [D:\cts\GTO\New Concept\workspace\SpringQuartz\exampleContext.xml]]
    Eagerly caching bean 'orderManager' to allow for resolving potential circular references
    Returning cached instance of singleton bean 'mailSender'
    Returning cached instance of singleton bean 'templateMessage'
    Publishing event in context [org.springframework.context.support.FileSystemXmlA [email protected]]: org.springframework.context.event.ContextRefreshed Event[source=org.springframework.context.support.FileSys [email protected]: display name [org.springframework.context.support.FileSystemXmlA [email protected]]; startup date [Fri May 11 14:10:51 GMT+05:30 2007]; root of context hierarchy]

  • #2
    I've usually found JavaMail problems to be related to the mail server you are trying to contact. The examples out there all typically work, it's just if they work with your mail server. It's always useful to up the logging and see if there's anymore information. Where are you trying to send the email?

    Comment


    • #3
      I am sending mail to the domain: yahoo.com.
      Is there any other properties that i need to set apart from the example for sending to the above domain

      Comment


      • #4
        I'd have a search on the net, people have problem with this kind of thing all the time. Might be the best option.

        Comment


        • #5
          did you configure correctly the mail session ? the smtp server for example ...

          Comment


          • #6
            I believe the mail session is taken care by spring internally.
            We just need to bind the Spring Class in a property file
            here is what i did

            Sending both the parameters through properties file
            mail.from = [email protected]
            mail.to = [email protected]


            Code:
            <bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
            		<property name="locations">
            			<list>
            				<value>mail.properties</value>
            			</list>
            		</property>
            	</bean>
            	
            	<!-- MailSender implementation for JavaMail -->
            	<bean id="springMailSender" class="org.springframework.mail.javamail.JavaMailSenderImpl">
            		<property name="host" value="${mail.host}"/>
            	</bean>
            	
            	<bean id="iMailDispatcher" class="com.spring.test.mail.ELiftMail">
            		<property name="mailSender" ref="springMailSender"/> 
            		<property name="mailFrom" value="${mail.from}"/>
            		<property name="mailTo" value="${mail.to}"/>
            	</bean>
            
            
            private String mailFrom;
            	private String mailTo;
            	private MailSender mailSender;
            
            	public void setMailFrom(String mailFrom) {
            		this.mailFrom = mailFrom;
            	}
            
            	public void setMailTo(String mailTo) {
            		this.mailTo = mailTo;
            	}
            
            	public void setMailSender(MailSender mailSender) {
            		this.mailSender = mailSender;
            	}
            	
            	public void process(){
            		
            		SimpleMailMessage message = new SimpleMailMessage();
            		String text = "hai from ELift";
            		message.setFrom(this.mailFrom);
            		message.setTo(this.mailTo);
            		message.setSubject("Image list");
            		message.setText(text);
            		this.mailSender.send(message);
            		System.out.print("Completed");
            	}

            Let me know if i need to do any change, though i am using the example of Spring framework.

            Comment


            • #7
              ok, i thought you were looking up by jndi a mail session defined in the application server, like this, instead of defining each single property
              Code:
              <bean name="mailSession" class="org.springframework.jndi.JndiObjectFactoryBean">
              	<property name="jndiName" value="java:/Mail"/>
              </bean>
              <bean name="mailSender" class="org.springframework.mail.javamail.JavaMailSenderImpl">
              	<property name="session" ref="mailSession"/>
              </bean>
              just a doubt ... is not the smtp address system property named "mail.smtp.host" instead of "mail.host" ?

              Comment


              • #8
                I've googled this and there are lots of existing discussions on this. I would have a look through them.
                e.g.
                http://forum.java.sun.com/thread.jspa?threadID=5171220
                http://developer.yahoo.net/blog/arch...7/03/mail.html

                Comment


                • #9
                  Originally posted by karldmoore View Post
                  I've googled this and there are lots of existing discussions on this. I would have a look through them.
                  e.g.
                  http://forum.java.sun.com/thread.jspa?threadID=5171220
                  http://developer.yahoo.net/blog/arch...7/03/mail.html
                  from what i see he is not saying that he is sending mail through (as in the examples in your links) yahoo but simply to a yahoo account.
                  Last edited by paolo_denti; May 18th, 2007, 03:03 PM.

                  Comment

                  Working...
                  X