الفريق العربي للبرمجةأرشيف المنتديات · 2000 – 2023
نسخة أرشيفية للقراءة فقط — التسجيل والمشاركة مغلقان، والمحتوى محفوظ كما كان.

طلب مساعد فى ارسال رسالة

بدأه yasmina1235 في 23 ديسمبر 2011 · 1 رد · 377 مشاهدة · في JavaSE
مشاركة: واتساب X فيسبوك تيليجرام
#1 صاحب الموضوع

السلام عليكم

لقد قمت بعمل برنامج لارسال رسالة عندما استعمل smtp.gmail.com" فاءن الرسالة ترسل اما عندما استعملsmtp.hotmail.fr" فتضهر لى المشاكل التالية

Exception in thread "main" java.lang.RuntimeException: javax.mail.MessagingException: Unknown SMTP host: smtp.hotmail.fr;

nested exception is:

java.net.UnknownHostException: smtp.hotmail.fr

at com.mkyong.common.SendMailSSL.main(SendMailSSL.java:44)

Caused by: javax.mail.MessagingException: Unknown SMTP host: smtp.hotmail.fr;

nested exception is:

java.net.UnknownHostException: smtp.hotmail.fr

at com.sun.mail.smtp.SMTPTransport.openServer(SMTPTransport.java:1932)

at com.sun.mail.smtp.SMTPTransport.protocolConnect(SMTPTransport.java:638)

at javax.mail.Service.connect(Service.java:317)

at javax.mail.Service.connect(Service.java:176)

at javax.mail.Service.connect(Service.java:125)

at javax.mail.Transport.send0(Transport.java:194)

at javax.mail.Transport.send(Transport.java:124)

at com.mkyong.common.SendMailSSL.main(SendMailSSL.java:39)

Caused by: java.net.UnknownHostException: smtp.hotmail.fr

at java.net.PlainSocketImpl.connect(Unknown Source)

at java.net.SocksSocketImpl.connect(Unknown Source)

at java.net.Socket.connect(Unknown Source)

at java.net.Socket.connect(Unknown Source)

at com.sun.mail.util.SocketFetcher.createSocket(SocketFetcher.java:288)

at com.sun.mail.util.SocketFetcher.getSocket(SocketFetcher.java:231)

at com.sun.mail.smtp.SMTPTransport.openServer(SMTPTransport.java:1900)

... 7 more

الكود :

package com.mkyong.common;

import java.util.Properties;
import javax.mail.Message;
import javax.mail.MessagingException;
import javax.mail.Session;
import javax.mail.Transport;
import javax.mail.internet.InternetAddress;
import javax.mail.internet.MimeMessage;

public class SendMailTLS {

	public static void main(String[] args) {
		String host = "smtp.gmail.com";
		int port = 587;
		String username = "username";
		String password = "password";

		Properties props = new Properties();
		props.put("mail.smtp.auth", "true");
		props.put("mail.smtp.starttls.enable", "true");

		Session session = Session.getInstance(props);

		try {

			Message message = new MimeMessage(session);
			message.setFrom(new InternetAddress("from@no-spam.com"));
			message.setRecipients(Message.RecipientType.TO,
				InternetAddress.parse("to@no-spam.com"));
			message.setSubject("Testing Subject");
			message.setText("Dear Mail Crawler," +
					"\n\n No spam to my email, please!");

			Transport transport = session.getTransport("smtp");
			transport.connect(host, port, username, password);

			Transport.send(message);

			System.out.println("Done");

		} catch (MessagingException e) {
			throw new RuntimeException(e);
		}
	}
}

;

package com.mkyong.common;

import java.util.Properties;
import javax.mail.Message;
import javax.mail.MessagingException;
import javax.mail.PasswordAuthentication;
import javax.mail.Session;
import javax.mail.Transport;
import javax.mail.internet.InternetAddress;
import javax.mail.internet.MimeMessage;

public class SendMailSSL {
	public static void main(String[] args) {
		Properties props = new Properties();
		props.put("mail.smtp.host", "smtp.gmail.com");
		props.put("mail.smtp.socketFactory.port", "465");
		props.put("mail.smtp.socketFactory.class",
				"javax.net.ssl.SSLSocketFactory");
		props.put("mail.smtp.auth", "true");
		props.put("mail.smtp.port", "465");

		Session session = Session.getDefaultInstance(props,
			new javax.mail.Authenticator() {
				protected PasswordAuthentication getPasswordAuthentication() {
					return new PasswordAuthentication("username","password");
				}
			});

		try {

			Message message = new MimeMessage(session);
			message.setFrom(new InternetAddress("from@no-spam.com"));
			message.setRecipients(Message.RecipientType.TO,
					InternetAddress.parse("to@no-spam.com"));
			message.setSubject("Testing Subject");
			message.setText("Dear Mail Crawler," +
					"\n\n No spam to my email, please!");

			Transport.send(message);

			System.out.println("Done");

		} catch (MessagingException e) {
			throw new RuntimeException(e);
		}
	}
}
#2

ابحث عن إعدادات hotmail

http://ask-leo.com/what_are_windows_live_hotmails_pop3_and_smtp_settings.html

إذا لم تعمل ابحث عن واحدة أخرى

تحياتي

حزمة المحرك الإصدارة 0.8

أي أحد يجد أني ظلمته فليراسلني

وبإذن الله لو كان له حق سيأخذه

728x90.png

مواضيع مشابهة