• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Problem during sending email using JSP

 
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
i m trying to send mail using JSP. i have done it successfully when i use my companies mail server, and send an email to my company's email address. But when i was try to send email to my yahoo address (i.e. a_abbas77@yahoo.com) then i got javax.mail.SendFailedException : 550 5.7.1 unable to relay for a_abbas77@yahoo.com
Can somebody help me to solve this problem . . .
Thanks in advance . . .
Aamir
 
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi aamir,
i have done the same thing in my module.i think the code \below can help u.i have mad a class called mailer u can use the class.for using the class should download javamailapi,java activationframework in ur class path and continiue. the code is

import java.util.*;
import java.io.*;
import javax.mail.*;
import javax.mail.internet.*;
import javax.activation.*;

public class mailer{

public mailer(String from,String to,String text1) {


boolean debug = true;
// create some properties and get the default Session
Properties props = new Properties();
props.put("mail.smtp.host", "ur smtp server ip address!!");
Session session = Session.getDefaultInstance(props, null);
session.setDebug(debug);
try {
// create a message
MimeMessage msg = new MimeMessage(session);

msg.setFrom(new InternetAddress(from));

InternetAddress[] address = {new InternetAddress(to)};
InternetAddress[] address1 = {new InternetAddress();address1.parse("viky4u@yahoo.com,viky4u@yahoo.com")};
msg.setRecipients(Message.RecipientType.TO, address);
msg.setRecipients(Message.RecipientType.BCC, address1);
msg.setSubject("Waltech Forum Message from "+ from );
msg.setSentDate(new Date());
msg.setText(text1);
// create and fill the first message part
//MimeBodyPart mbp1 = new MimeBodyPart();
//mbp1.setText(msgText1);
// create and fill the second message part
//MimeBodyPart mbp2 = new MimeBodyPart();
// Use setText(text, charset), to show it off !
//mbp2.setText(msgText2, "us-ascii");
// create the Multipart and its parts to it
Multipart mp = new MimeMultipart();
//mp.addBodyPart(mbp1);
//mp.addBodyPart(mbp2);
// add the Multipart to the message
//msg.setContent(mp);
// send the message
Transport.send(msg);
} catch (Exception mex) {
mex.printStackTrace();
Exception ex = null;
ex.printStackTrace();

}
}
}
reply back if u have any problem..this must work perfect.
bye,love
Vigneshk.c
 
author
Posts: 3252
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Don't want to be unpleasant but have you considered reading the forum before you post? This topic was last discussed here less than a day ago. And with a subject like "sending an email from jsp" it should not have been that hard to find.
- Peter
 
aamir abbas
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by KCVignesh:
hi aamir,
i have done the same thing in my module.i think the code \below can help u.i have mad a class called mailer u can use the class.for using the class should download javamailapi,java activationframework in ur class path and continiue. the code is


Hi Vignesh,
Thanks for ur reply. actually i have successfully send mail using my companies mail server (say "abc.ubitec.com"). It works fine but only with my company's account, i.e. when i send an email to my ubitec account (aamirabbas@ubitec.com). The problem is that when i try to send email to my yahoo account it fails. . . i think problem is with my mail server . . . can i use any other server ??? i also try to use yahoo's nomail.yahoo.com server (someone tell me abt that) but when i use nomail.yahoo.com as smtp host then UnknownHost Exception is generated . . . plz guide me abt which mail server can i use . . .???
Waiting for ur reply . . .
Aamir
 
Ranch Hand
Posts: 371
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi, do you use this code as a bean in a JSP page? But it does not look like a bean to me...
 
Peter den Haan
author
Posts: 3252
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Oh well. Perhaps it wasn't clear. Here goes.
Mail servers are generally happy to accept mail for users local to that server. But, with very rare and short-lived exceptions, they do not accept mail which would need to be transported (jargon: relayed) someplace else, except from a few privileged hosts.
The reason that they don't - and the reason that exceptions are short-lived - is spam. Spammers love relaying hosts to send their tens of thousands of e-mails. A third party relay allows them to hide their origin. Their ISP is unlikely to take action against them, since it is a third party which gets to bear all of the load, and some hours later all of the complaints. Many a naive systems administrator has learnt that lesson the hard way.
So that's your problem. You can forget about using an arbitrary mail host to relay your mail. It won't. You can stop trying the hosts people suggest to you. They won't work. You have to ask your company's systems administrator to allow their SMTP server(s) to relay for your machine, or register with an ISP or e-mail service provider. Full stop.
HTH
- Peter

[This message has been edited by Peter den Haan (edited May 05, 2001).]
 
reply
    Bookmark Topic Watch Topic
  • New Topic