Tuesday, February 3, 2009

Spring Mail and Gmail SMTP server

Spring Mail and Gmail SMTP server

February 1, 2008 at 9:04 pm · Filed under open source, spring

In case you need to use Spring Mail with Gmail SMTP server, first of all configure a mail sender bean:

<!-- Mail Sender -->
<bean
id= "mailSender" class= "org.springframework.mail.javamail.JavaMailSenderImpl" >
  <property
name= "host" value= "${mail.host}" />
  <property
name= "port" value= "${mail.port}" />
  <property
name= "username" value= "${mail.username}" />
  <property
name= "password" value= "${mail.password}" />
  <property
name= "protocol" value= "${mail.protocol}" />
  <property
name= "javaMailProperties" >
    <props>
      <prop
key= "mail.smtps.auth" >true</prop>
      <prop
key= "mail.smtps.starttls.enable" >true</prop>
      <prop
key= "mail.smtps.debug" >true</prop>
    </props>
  </property>
</bean>

We could take to a property file the relevant properties:

mail.
host = smtp. googlemail . com
mail.
port = 465
mail.
username = yourUsername
mail.
password = yourPassword
mail.
protocol = smtps

Let’s see an integrational test for this:

public class SimpleMailSenderTest extends AbstractDependencyInjectionSpringContextTests {
  
protected MailSender mailSender ;
  
public SimpleMailSenderTest () {
    setPopulateProtectedVariables
( true );
  
}
  @
Override
  
protected String [] getConfigLocations () {
    
return new String [] { ”applicationContext. xml ” };
  
}
  
public void testSendEmail () throws Exception {
    SimpleMailMessage simpleMessage =
new SimpleMailMessage ();
    simpleMessage.
setFrom ( ”fromEmail” );
    simpleMessage.
setTo ( ”toEmail” );
    simpleMessage.
setText ( ”Testing text” );
    simpleMessage.
setSubject ( ”Testing subject” );
    mailSender.
send ( simpleMessage );
  
}
}

In case we have a template for sending these emails we could define a template message bean:

<bean
id= "templateMessage" class= "org.springframework.mail.SimpleMailMessage" >
  <property
name= "from" value= "fromAddress" />
  <property
name= "to" value= "toAddress" />
</bean>

Alternatively, we could also specify replyTo, cc, bcc, sentDate, subject and text.



Spring Mail and Gmail SMTP server

Spring Mail and Gmail SMTP server

February 1, 2008 at 9:04 pm · Filed under open source, spring

In case you need to use Spring Mail with Gmail SMTP server, first of all configure a mail sender bean:

<!-- Mail Sender -->
<bean
id= "mailSender" class= "org.springframework.mail.javamail.JavaMailSenderImpl" >
  <property
name= "host" value= "${mail.host}" />
  <property
name= "port" value= "${mail.port}" />
  <property
name= "username" value= "${mail.username}" />
  <property
name= "password" value= "${mail.password}" />
  <property
name= "protocol" value= "${mail.protocol}" />
  <property
name= "javaMailProperties" >
    <props>
      <prop
key= "mail.smtps.auth" >true</prop>
      <prop
key= "mail.smtps.starttls.enable" >true</prop>
      <prop
key= "mail.smtps.debug" >true</prop>
    </props>
  </property>
</bean>

We could take to a property file the relevant properties:

mail.
host = smtp. googlemail . com
mail.
port = 465
mail.
username = yourUsername
mail.
password = yourPassword
mail.
protocol = smtps

Let’s see an integrational test for this:

public class SimpleMailSenderTest extends AbstractDependencyInjectionSpringContextTests {
  
protected MailSender mailSender ;
  
public SimpleMailSenderTest () {
    setPopulateProtectedVariables
( true );
  
}
  @
Override
  
protected String [] getConfigLocations () {
    
return new String [] { ”applicationContext. xml ” };
  
}
  
public void testSendEmail () throws Exception {
    SimpleMailMessage simpleMessage =
new SimpleMailMessage ();
    simpleMessage.
setFrom ( ”fromEmail” );
    simpleMessage.
setTo ( ”toEmail” );
    simpleMessage.
setText ( ”Testing text” );
    simpleMessage.
setSubject ( ”Testing subject” );
    mailSender.
send ( simpleMessage );
  
}
}

In case we have a template for sending these emails we could define a template message bean:

<bean
id= "templateMessage" class= "org.springframework.mail.SimpleMailMessage" >
  <property
name= "from" value= "fromAddress" />
  <property
name= "to" value= "toAddress" />
</bean>

Alternatively, we could also specify replyTo, cc, bcc, sentDate, subject and text.



Thursday, January 22, 2009

One liners -- Hidden meanings in Company talk

One liners -- Hidden meanings in Company talk
Today's Professional Management FUNDAS

1."We will do it" means "You will do it"

2."You have done a great job" means "More work to be given to you"

3."We are working on it" means "We have not yet started working on the same"

4."Tomorrow first thing in the morning" means "Its not getting done "At least not tomorrow!"

5."After discussion we will decide-I am very open to views" means "I have already decided, I will tell you what to do"

6."There was a slight miscommunication" means "We had actually lied"

7."Lets call a meeting and discuss" means "I have no time now, will talk later"

8."We can always do it" means "We actually cannot do the same on time"

9."We are on the right track but there needs to be a slight extension of the deadline" means "The project is screwed up, we cannot deliver on time."

10."We had slight differences of opinion "means "We had actually fought"

11."Make a list of the work that you do and let's see how I can help you" means "Anyway you have to find a way out no help from me"

12."You should have told me earlier" means "Well even if you told me earlier that would have made hardly any difference!"

13."We need to find out the real reason" means "Well I will tell you where your fault is"

14."Well Family is important; your leave is always granted. Just ensure that the work is not affected," means, "Well you know..."

15."We are a team," means, "I am not the only one to be blamed"

16."That's actually a good question" means "I do not know anything about it"

17."All the Best" means "You are in trouble"

Tuesday, November 18, 2008

Virtual box back up and restore VDI files

The command is this:

VBoxManage clonevdi /home/winship/.VirtualBox/VDI/WinXP.vdi /media/storage2/tmp/WinXP.vdi

To restore it, go to File->Virtual Disk Manager->Add and select your backup .vdi file


Sunday, September 28, 2008

CSS browser hacks

height:10px;
_height:20px;/* ignored by IE6 */

*height:20px;/* ignored by IE7 */

#container[id] { width: 820px; } /* ignored by IE */


Wednesday, July 16, 2008

Read resource files from class library: resx files from dll

set up for resource files in Visual studio:





Add the below line in your class

ResourceManager rm = new ResourceManager("%NAMESPACE TO BE REPLACE WITH THE DEFUAT NAMESPACE OF LIBRARY%.ErrorMessages", Assembly.GetExecutingAssembly());
rm.GetString("%RESOURCE KEY HERE%");


thats it ,... to read resource in a dll from the same dll

Thursday, February 14, 2008

How to exclude .svn folders from project -Eclipse

Ref:
http://pyre.third-bit.com/blog/archives/101.html
http://lists.ofbiz.org/pipermail/dev/2006-January/009586.html
http://www.malcolmhall.com/?p=98

I’ve just began using Eclipse instead of IntelliJ and one thing had me stumped for an hour. My src folder was under SVN but my bin folder wasn’t, however when I compile, the tortoise plugin for windows explorer suddenly showed the bin folder as under SVN with an exclamation over the folder icon. What was going on? It appears that when Eclipse builds, it copies any files and folders form the src folder to the bin folder including the .svn hidden folders. I had just about given up with Eclipse then I started hunting for a way to manually exclude the .svn folders from the build. A few attempts at making my own exclude pattern which only worked in a few cases I finally found this neat solution on the web:

Modify the project’s java build path to exclude the pattern **/.svn/

Here’s complete directions:
Project / Properties / Java Build Path / Source / unfold your project / Excluded / Edit / Exclusion patterns / Add / “**/.svn/*”