1 #Python Code ဖြင့် email ပို့ခြင်း 2 # email ပို့ရန် smtplib module ကို import လုပ်သည်။ 3 import smtplib 4 5 # မိမိ email account နှင့် password ထည့်ပေးရန် initialize လုပ်သည်။ 6 my_mail = "your.name@gmail.com" 7 password="123$your$password& 8 9 # gmail account သုံးသူများအတွက် "smtp.gmail.com" ဖြစ်သည်။ 10 # smtplib.SMTP() ဖြင့် gmail account အား connection လုပ်မည်။ 11 connection = smtplib.SMTP("smtp.gmail.com") 12 13 connection.starttls() # make connection secure 14 # connection ဖြစ်ပြီးနောက် gmail account နှင့် password ထည့်ပေးသည်။ 15 connection.login(user=my_mail, password=password) 16 # sendmail() function ဖြင့် mail ပို့မည်။ 17 # from_addr သည် မိမိ၏ gmail account ဖြစ်သည်။ to_addrs သည် မိမိပို့လိုသည့် address ဖြစ်သည်။ 18 # msg သည် မိမိပို့လိုသည့် message ဖြစ်သည်။ 19 connection.sendmail(from_addr =my_mail, to_addrs="kaung_htat@hotmail.com", msg= "Subject: Test python email second time\n\n This is body of my email.") 20 # mail ပို့ပြီးပါက connection ကို ပြန်ပိတ်မည်။ 21 connection.close() 22 #email seeting မပြောင်းရသေးပါက အောက်တွင် ပြထားသည့် SMTPAuthenticationError ရရှိလိမ့်မည်။23 # Gmail account မှ setting နှစ်ခု ပြောင်းပေးရန်လိုသည်။ ထိုသို့ ပြောင်းြခင်းကြောင့် security သိမကောင်းတော့သည်ကို သတိပြုပါ။ gmail account အသစ်တစ်ခု ပြုလုပ်၍ စမ်းသင့်သည်. " 23 # Gmail account မှ Manage Your account ကို click ပါ။ Security ကို click ပါ။ "
![]()
![]()
23 #Yahoo account ဖြစ်ပါက "smtp.mail.yahoo.com" 23 #အောက်တွင် ဖော်ပြထားသည့် with .. as ဖြင့်လည်း ရေးနိုင်သည်။ 24 25 with smtplib.SMTP("smtp.gmail.com") as connection: 26 connection.starttls() # make connection secure 27 connection.login(user=my_mail, password=password) 28 connection.sendmail( 29 from_addr =my_mail, to_addrs="kaung_htat@hotmail.com", 30 msg= "Subject: Test python email\n\n This is body of my email." 31 ) 32 33