Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Jsp mail problem

Status
Not open for further replies.

Khanjan

Programmer
Feb 24, 2004
41
0
0
NL
Hi,

I want to send email, but i am not able to do so.

Below is my code.

What is wrong with this????

SMTP = smtp.quicknet.nl

Code::::::

<%@ page language="java" import="java.util.*, javax.mail.*, javax.mail.internet.*"%>
<%
// create the HTML email message to send
String htmlText = "";
htmlText += "<html><head>";
htmlText += "<style type=\"text/css\">";
htmlText += "body {font-family:verdana;font-size:10pt;margin:10px;}";
htmlText += "</style></head>";
htmlText += "<body>";
htmlText += "<p>This is a sample <b>HTML</b> email using the JavaMail APIs.</p>";
htmlText += "</body></html>";

String mailServer = "smtp.quicknet.nl"; // your mail server IP
String fromAddress = "samirkabuli@yahoo.com";
String toAddress = "fahimkabuli@hotmail.com";
String subjectText = "Internet generated email"; // the email subject

Properties props = new Properties();
props.put("mail.smtp.host", mailServer);
Session sesh = Session.getDefaultInstance(props,null);
MimeMessage message = new MimeMessage(sesh);
message.setContent(htmlText, "text/html");
InternetAddress from = new InternetAddress(fromAddress);
message.setFrom(from);
InternetAddress to = new InternetAddress(toAddress);
message.addRecipient(Message.RecipientType.TO, to);
message.setSubject(subjectText);
Transport.send(message);

out.println("gelukt of niet");
%>
 
I must say, i dont get any ERROR, when i excute this code.

I dont get any email either
 
Hi,

I copied your code and changed the mail.smtp.host to my host and email Adresses. I was able to receive the E-Mail.
May be try to change the email address or contact your smtp.host provider.

Cheers
Venu
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top