အီးမေးလ်သည်ခေတ်သစ်ကွန်ယက်ဆက်သွယ်ရေးအတွက်မရှိမဖြစ်လိုအပ်သောကိရိယာတစ်ခုဖြစ်သည်။ အထူးသဖြင့် Web Development တွင်အသုံးပြုသူမှတ်ပုံတင်ခြင်း, လျှို့ဝှက်နံပါတ်ပြန်လည်အသိပေးခြင်းစသည့်ဖြစ်စဉ်များတွင်အီးမေးလ်ပို့ခြင်း function တွင်ကျယ်ပြန့်စွာအသုံးပြုသည်။ ဤဆောင်းပါးသည် Mail, SMTP နှင့် Phpmailer အပါအ 0 င် PHP Mail Sending ၏ဘုံလုပ်ဆောင်မှုများကိုအသေးစိတ်ဖော်ပြပေးပြီး developer များပိုမိုကောင်းမွန်စွာအကောင်အထည်ဖော်ရန်ကူညီရန်သက်ဆိုင်ရာကုဒ်များဥပမာများကိုအသေးစိတ်ဖော်ပြထားသည်။
Mail function သည် PHP တွင်ပါ 0 င်သော Mail Sending function ဖြစ်သည်။ ၎င်းသည်ရိုးရှင်းသောလွင်ပြင်စာသားမက်ဆေ့ခ်ျပို့ရန်အသုံးပြုသည်။ အခြေခံ syntax သည်အောက်ပါအတိုင်းဖြစ်သည် -
<span class="fun">Bool Mail (string $ မှရန်, string $ အကြောင်းအရာ, string ကို $ မက်ဆေ့ခ်ျပို့, string $ အပို: ', string ကို $ အပိုဆောင်း $ အပိုဆောင်း $ အပိုဆောင်း airs_harameters =' '',</span>
parameter သည်ဖော်ပြချက်:
မေးလ် function ကိုအသုံးပြုပြီးရိုးရှင်းသောစာသားမက်ဆေ့ခ်ျများကိုပို့ရန်နမူနာကုဒ်ဖြစ်သည်။
<span class="fun">$ to = "Extal@example.com";</span>
<span class="fun">$ ဘာသာရပ် = "Test Mail";</span>
<span class="fun">$ message = "ဒါကအီးမေးလ်ပဲ။ ";</span>
<span class="fun">$ headers = "ကနေ: Sender@example.com";</span>
<span class="fun">IF (မေးလ် ($ သို့, $ ဘာသာရပ်, $ မက်ဆေ့ခ်ျ, $ headers))</span>
<span class="fun"> ECHO "အီးမေးလ်ကိုအောင်မြင်စွာပို့လိုက်ပြီ";</span>
<span class="fun">} အခြား</span>
<span class="fun"> Echo "အီးမေးလ်ပို့ခြင်းမအောင်မြင်ပါ။ ";</span>
<span class="fun">}</span>
SMTP function သည် SMTP Protocol ပေါ်တွင် အခြေခံ. SMTP protocol ကို အခြေခံ. Mails Mails များ, ပူးတွဲဖိုင်များနှင့်ချိတ်ဆက်ရန်သင့်တော်သောစာများပို့သည့် function တစ်ခုဖြစ်ပြီးဤ function ကိုအသုံးပြုရန်အတွက်သင့်လျော်သော PHP configuration file ရှိသက်ဆိုင်ရာ extension ကို ဦး စွာဖွင့်ပြီး SMTP server အချက်အလက်ကိုပြင်ဆင်ရန်နှင့် SMTP ဆာဗာအချက်အလက်များကိုပြင်ဆင်ပါ။
SMML mail ကို SMTP function ကို အသုံးပြု. HTML Mail ကိုပို့ရန်နမူနာကုဒ်ဖြစ်သည်။
<span class="fun">'SMTP.PHP', // SMTP အတန်းစာကြည့်တိုက်မိတ်ဆက်ပေးသည်</span>
<span class="fun">$ SMTP = SMTP အသစ် (),</span>
<span class="fun">$ smtp-> ဆာဗာ = "SMTP.EXAXPORCAPLOCCALCONCORCONCORD;</span>
<span class="fun">$ SMTPP-> User = "Username";</span>
<span class="fun">$ smtp-> စကားဝှက် = "စကားဝှက်";</span>
<span class="fun">$ to = "Extal@example.com";</span>
<span class="fun">$ ဘာသာရပ် = "HTML Mail Test";</span>
<span class="fun">$ message = "<html> <body> <h1> ဒါကစမ်းသပ်မှုအီးမေးလ်တစ်ခုဖြစ်ပါတယ် </ h1> <p> ဒါကစမ်းသပ်အီးမေးလ်ရဲ့အဓိကအကြောင်းအရာပါ။ </ p> </ body> </ html>"</span>
<span class="fun">$ headers = "Mime-version: 1.0" ။ "\ r \ n" ။ "အကြောင်းအရာအမျိုးအစား: စာသား / HTML; Charset = UTF-8";</span>
<span class="fun">IF ($ SMTPP-> Sendmail ($ သို့ $ ဘာသာရပ်, $ မက်ဆေ့ခ်ျ, $ headers)) {</span>
<span class="fun"> ECHO "အီးမေးလ်ကိုအောင်မြင်စွာပို့လိုက်ပြီ";</span>
<span class="fun">} အခြား</span>
<span class="fun"> Echo "အီးမေးလ်ပို့ခြင်းမအောင်မြင်ပါ။ ";</span>
Phpmailer သည် PHP တွင်စာကြည့်တိုက်ပို့ခြင်းအလွန်အစွမ်းထက်သောအီးမေးလ်ဖြစ်သည်။ ၎င်းသည်ပုံမှန်အီးမေးလ်များ, HTML အီးမေးလ်များနှင့်အီးမေးလ်များကိုပူးတွဲဖိုင်များပေးပို့ခြင်းကိုထောက်ခံသည်။ Phpmailer သည် configuration options များကိုပိုမိုထောက်ပံ့ပေးပြီးအမှားကိုင်တွယ်သည့်ယန္တရားတစ်ခုရှိသည်။ ၎င်းသည် PHP ဖွံ့ဖြိုးတိုးတက်မှုရှိစာကြည့်တိုက်များပို့သည့်စာကြည့်တိုက်များပို့သည့်အသုံးပြုသောမေးလ်တစ်ခုဖြစ်သည်။
Phpmailer Class စာကြည့်တိုက်ကို အသုံးပြု. စာသားမက်ဆေ့ခ်ျများကိုပို့ရန်နမူနာကုဒ်ဖြစ်သည်။
<span class="fun">'Phpmailer / Phpmailer.php လိုအပ်သည်။ // phpmailer လူတန်းစားစာကြည့်တိုက်မိတ်ဆက်ပေး</span>
<span class="fun">$ mail = phpmailerphppipmailphipmailer ();</span>
<span class="fun">$ မေးလ် -> ISSMTP ();</span>
<span class="fun">$ မေးလ် -> host = "SMTP.ExAXPH.com";</span>
<span class="fun">$ မေးလ် -> SMTPAUTH = TRUE;</span>
<span class="fun">$ မေးလ် -> Username = "Username";</span>
<span class="fun">$ မေးလ် -> စကားဝှက် = "စကားဝှက်";</span>
<span class="fun">$ မေးလ် -> SSLECure = "SSL";</span>
<span class="fun">$ မေးလ် -> port = 465;</span>
<span class="fun">$ မေးလ် -> Charset = "Utf-8";</span>
<span class="fun">$ mail-> setfrom (Sender@example.com "," ပေးပို့သူ "),</span>
<span class="fun">$ မေးလ် -> ADDADDRANDRESS ("Experirey@example.com");</span>
<span class="fun">$ မေးလ် -> ဘာသာရပ် = "Plain Text Mail Test";</span>
<span class="fun">$ မေးလ် -> ခန္ဓာကိုယ် = "ဒါကစမ်းသပ်မှုတစ်ခုတည်းစာသားအီးမေးလ်ပါ။ ";</span>
<span class="fun">လျှင် ($ မေးလ် -> Send ()) {</span>
<span class="fun"> ECHO "အီးမေးလ်ကိုအောင်မြင်စွာပို့လိုက်ပြီ";</span>
<span class="fun">} အခြား</span>
<span class="fun"> Echo "အီးမေးလ်ပို့ခြင်းမအောင်မြင်ပါ။ " ။ $ mail-> errorinfo;</span>
ဤဆောင်းပါးသည် Mail functions များ, smtp protocol နှင့် phpmailer လူတန်းစားစာကြည့်တိုက်နှင့် Phpmailer လူတန်းစားစာကြည့်တိုက်များအသုံးပြုခြင်းအပါအ 0 င် PHP တွင်အသုံးပြုသော PHP တွင်အသုံးပြုသောစာပို့သည့်နည်းလမ်းများကိုအသေးစိတ်ဖော်ပြထားသည်။ ဤနည်းလမ်းများမှတစ်ဆင့် developer များက၎င်းတို့၏လိုအပ်ချက်များနှင့်အညီသင့်လျော်သောအီးမေးလ်ကို ရွေးချယ်. ရိုးရိုးရှင်းရှင်းသို့မဟုတ်ရှုပ်ထွေးသောအီးမေးလ်ပို့ခြင်းလုပ်ဆောင်ချက်များကိုနားလည်သဘောပေါက်နိုင်သည်။ ဤဆောင်းပါး၏မိတ်ဆက်ခြင်းသည် developer များပိုမိုကောင်းမွန်သော Master Php အီးမေးလ်ကိုပိုမိုကောင်းမွန်အောင်ပြုလုပ်နိုင်ရန်နှင့်ဖွံ့ဖြိုးရေးထိရောက်မှုကိုတိုးတက်စေရန်ကူညီနိုင်သည်ဟုကျွန်ုပ်မျှော်လင့်ပါသည်။