|
蓝森林 http://www.lslnet.com 2006年6月6日 10:18
!!我的第一个JavaMail程序,请教!!
代码:
import javax.mail.*;
import javax.activation.*;
import javax.mail.internet.*;
import java.util.Properties;
public class sendmail
{
public static void main(String args[])
{
String host="smtp.yahoo.com.cn";
String from="[email]shi2002ming@yahoo.com.cn[/email]";
String to="[email]shiming209@yahoo.com.cn[/email]";
try
{Properties props=System.getProperties();
props.put("mail.smtp.host",host);
Session session=Session.getDefaultInstance(props,null);
MimeMessage message=new MimeMessage(session);
message.setFrom(new InternetAddress(from));
message.addRecipient(Message.RecipientType.TO,new InternetAddress(to));
message.setSubject("hello,shiming!");
message.setText("this is my first javamail");
Transport.send(message);
System.out.println("发送成功!");
}
catch(Exception e){System.out.println("JavaMail配置有问题!"+e);}
}
}
运行抛出异常,说SMTP配置的问题,难道Yahoo不提供SMTP服务?还是其它原因?请教一下大家.
|
看样子是解析不到 那个地址 |
请教一下要怎样解决呢?
不能解析最终是因什么原因引起的呢?
能说明白一点吗?
多谢!!! |
C:>ping smtp.yahoo.com.cn
Unknown host smtp.yahoo.com.cn. |
-->
根据楼上意思是因为找不到服务器的原因了,那也就是说Yahoo不提供SMTP服务。还是其它原因?
请问一下有哪些大型服务器在提供SMTP服务呢? |
请教此问题怎样才能解决啊!多谢先! |
lz,我要找板砖拍死你.....
请了解 ping 的意思,这服务器有没提供 SMTP 服务先不说,连通都成问题啊
[code]
C:>ping smtp.yahoo.com.cn
Unknown host smtp.yahoo.com.cn.
[/code] |
哈哈,E文太差,没去太多留意。麻烦大家了。 |
| |