Mustaqilish


Javada elektron pochta ilovasini yaratish


Download 0.5 Mb.
bet3/3
Sana24.03.2023
Hajmi0.5 Mb.
#1292652
1   2   3
Bog'liq
TDA 2-mustaqil ish

Javada elektron pochta ilovasini yaratish


Java dasturlash tilida elektron pochta ilovasini yaratishda biz Intellij IDEA dasturiy muhitidan foydalanamiz. Elektron pochta ilovasini yaratish uchun Main.java clasini yaratamiz :

Elektron pochta protokollaridan foydalanish imkoniyatini beruvchi kerakli kutubxonalarni import qilamiz va quyidagicha kod yozamiz:


Main.java faylini ishga tushiramiz va quyidagicha natijaga ega bo’lamiz:

Elektron pochtamizga kirib ko’rganimizda yuqoridagi kodimiz ishlaganini ko’rishimiz mumkin:

Ko’rib turganingizdek bizning pochtamizga elektron pochtadan xabar keldi. Biz Java dasturlash tili va uning kutubxonalari yordamida bir elektron pochtadan boshqa elektron pochtaga xabar jo’natishni amalga oshirdik.

XULOSA


Biz yuqorida Java dasturlash tili orqali elektron pochtadan foydalandik. Ya’ni dasturchilar foydalanishi mumkin bo’lgan API lardan foydalangan holda elektrn pochtadan xabar jo’natdik. Bizni misolimizda bir elektron pochtadan boshqasiga xabar jo’natish keltirib o’tildi. Biz Java dasturlash tili va uning kutubxonalari orqali elektron pochta ning boshqa imkoniyatlaridan ham foydalanishimiz mumkin. Elektron pochtadan foydalanish uchun turli protokollardan foydalanish mumkin. Javada yaratilgan kutubxonalar yordamida elektron pochtadan faylli , ovozli, video xabarlar jo’natish mumkin.Java dasturlash tili elektron pochta va yana boshqa shu kabi ilovalarni yaratish uchun keng imkoniyatlarga ega.
ADABIYOTLAR RO‘YXATI

  1. https://www.geeksforgeeks.org/top-10-libraries-every-java-developer-shouldknow/

  2. https://en.wikipedia.org/wiki/Internet_Message_Access_Protocol

  3. https://www.techtarget.com/whatis/definition/POP3-Post-Office-Protocol-3

ILOVALAR
Yuqorida bajarilgan dastur kodlari
1.Main.java fayli
package com.company;
import javax.mail.*; import javax.mail.internet.InternetAddress; import javax.mail.internet.MimeMessage; import java.util.Properties;
public class Main { public static void main(String[] args) {
// Recipient's email ID needs to be mentioned.
String to = "shaxzodxudoyberdiyev77@gmail.com ";//change accordingly
// Sender's email ID needs to be mentioned
String from = "azizbekumurov@mail.ru";//change accordingly final String username = "azizbekumurov@mail.ru";//change accordingly final String password = "vxVxT0Av9xdBzeg86RvV";//change accordingly
// Assuming you are sending email through relay.jangosmtp.net
String host = "smtp.mail.ru"; Properties props = new Properties(); props.put("mail.smtp.auth", "true"); props.put("mail.smtp.starttls.enable", "true"); props.put("mail.smtp.host", host); props.put("mail.smtp.port", "465"); props.put("mail.smtps.ssl.checkserveridentity", true); props.put("mail.smtps.ssl.trust", "*"); props.put("mail.smtp.ssl.enable", "true");
// Get the Session object.
Session session = Session.getInstance(props,new javax.mail.Authenticator()
{ protected PasswordAuthentication getPasswordAuthentication()
{ return new PasswordAuthentication(username, password);
}
});
try {
// Create a default MimeMessage object.
Message message = new MimeMessage(session);
// Set From: header field of the header. message.setFrom(new InternetAddress(from)); // Set To: header field of the header.
message.setRecipients(Message.RecipientType.TO, InternetAddress.parse(to)); // Set Subject: header field message.setSubject("Assalomu alaykum"); // Now set the actual message message.setText("Bu xabar Java dan jo'natildi");
// Send message
Transport.send(message);
System.out.println("Xabar muvaffaqiyatli jo'natildi....");
} catch (MessagingException e) { throw new RuntimeException(e);
}
}
}
Download 0.5 Mb.

Do'stlaringiz bilan baham:
1   2   3




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©fayllar.org 2024
ma'muriyatiga murojaat qiling