<< June 2007 | Home | August 2007 >>

Javamail and Google mail SMTP server

How to send e-mails using Javamail API and SMTP server over SSL and authentication

Google mail provides a very convenient feature for spreading SPAM mails as a free SMTP server. I used it with success from my small custom SPAM mailing program, however when I tried to tune my Javamail based code, I met some problems. Finally I resolved them, so I decided to share my experience.

Prerequisites

  1. Make sure that you have Javamail API 1.4 or above
  2. Pop3 activated for gmail account

Configuration

The code below demonstrate required settings for successful usage of gmail SMTP server requiring SSL and authentication.

String ssl = "s";

Properties props = new Properties();

props.put("mail.smtp" + ssl + ".auth", "true");

props.put("mail.smtp" + ssl + ".quitwait", "false");

props.put("mail.smtp" + ssl + ".port", port); // port = 465

Session session = Session.getDefaultInstance(props, null);

// prepare message here

Transport tr = session.getTransport("smtp" + ssl);

tr.connect(host, "dmitriy@gmail.com", "mypupsy"); // 2nd - target email addr, 3rd - password

tr.sendMessage(msg, msg.getAllRecipients());

tr.close();

iPhone a serious design flaw

How to take over of it

I think Apple used very smart solution for custom applications for iPhone. Apple used JavaScript based web 2.0 application. Scripting language approach is very powerful and very simple. So you do not need to deal with ssh, web servers, native or Java code to create application for iPhone. Apple JavaScript can access some internal data from your iPhone and store some data there as well. It allows you to make really useful applications which can persist some information. However this approach creates a serious problem. JavaScript can transfer personal information to web server, it means there is a serious security flaw. I hope Apple will solve this problem. I think they can add just a simple warning box telling that JavaScript is going to transfer your personal information to the web site. So if you trust to the site, then you can grant such access or decline it. You can also mark some sites as trusted to eliminate extra requests. What do you think? Can such solution be protective enough?

iPhone: my thoughts

or will you buy it when you can afford it?

I've had a strong plan to replace my presenting Razr by iPhone, so almost was ready to buy it at the first day. However I had planned a trip where I can't use it, so I decided a wait for a month. Meantime I did a little research, and what's disappointment. iPhone has serious drawbacks for me like:
  1.  no support corporative e-mail
  2.  no disk mode, and what more important no 3rd party management programs and possibility use under Linux
  3. No voice dial
  4. No cut/paste
  5. No Java applications
So after long thoughts I decided to look at Blackberry 8820, it seems having all required features.