PHP Attachment mail
Saturday, 28 February 2009 18:26
ကြၽန္ေတာ္ေရးခဲ့ဘူးတဲ့ PHP Attachment Mail အေၾကာင္းကို ျပန္ေရးမယ္လို႔ စိတ္ကူးထားပါတယ္။ PHP မွာ Attachment မပါပဲ
mail send တာက လြယ္တယ္။ ဒီ function ေလးကိုေခၚျပီး parameter ေပးလိုက္႐ုံပါပဲ။
Syntax
| Parameter | Description |
|---|---|
| to | Required. Specifies the receiver / receivers of the email |
| subject | Required. Specifies the subject of the email. Note: This parameter cannot contain any newline characters |
| message | Required. Defines the message to be sent. Each line should be separated with a LF (\n). Lines should not exceed 70 characters |
| headers | Optional. Specifies additional headers, like From, Cc, and Bcc. The additional headers should be separated with a CRLF (\r\n) |
| parameters | Optional. Specifies an additional parameter to the sendmail program |
| mail(to,subject,message,headers,parameters) |
Ref: http://www.w3schools.com/PHP/php_mail.asp
ဒါေပမယ့္ Attachment File နဲ႔ send ရင္ေတာ့ နဲနဲစားတယ္။ ကြၽန္ေတာ္လည္း googling လုပ္ရင္ reference လုပ္လို႔ေကာင္းတဲ့
php mail library ေလးတစ္ခုကို သြားေတြ႕ပါတယ္။ တျခား php mail attachment script ေတြထက္ပိုမိုက္တယ္ဗ်။ သူထဲမွာ
function ေတြရွိျပီးသား ကိုယ္က ေခၚသုံးတတ္ဖို႔ပါပဲ။ ေရးထားတဲ့သူကေတာ့ france ျဖစ္ဖို႔မ်ားပါတယ္။ ဒီ mail lib ကိုလိုခ်င္တယ္
ဆိုရင္ ဒီမွာ ေဒါင္း လို႔ ရပါတယ္။ documentation ကိုလည္း အဲဒီ link မွာဖတ္ႏိုင္ပါတယ္။ အဲဒီ mail lib ကိုသုံးျပီး attachment နဲ႔
mail send တာကို ေျပာမွာ ျဖစ္ပါတယ္။ attachment နဲ႔ mail send မယ္ဆိုရင္ ဒီ concept ကိုသိထားရပါမယ္။ ကိုယ္ Browse
လုပ္ျပီး select လုပ္ထားတဲ့ file ကို server ေပၚက tmp location တစ္ခုေပၚကို အရင္တင္ပါတယ္။ ျပီးမွ အဲဒီ file ကို php ရဲ႔
file object သုံးျပီး attachment send လို႔ရတဲ့ format ေျပာင္းပါတယ္။ အားလုံးျပီးျပီဆိုမွ php mail function ထဲကို pass
လုပ္ေပးလိုက္တာပါ။
1). copy function ကိုသုံးျပီး file upload ထားတဲ့ temporary location ကေနျပီး mail attachment ေတြထားတဲ့ location ကို
file copy ကူးလိုက္ပါတယ္။
$file2=$_FILES['attfile'];
attachment file input ကေနျပီး file object သုံးျပီး ဖတ္တာပါ။
copy($file2[tmp_name], "email/".$file2[name])
$file3=$file2[name];
2). mail lib ကိုေခၚျပီး mail send ပါမယ္။
$admin_email="admin@urdomain.com.";
$to = "urmail@urdomain.com";
$m = new Mail(); // create the mail
$m->From( $admin_email );
$m->To($to );
$m->Subject( "Attachment Mail Testing." );
$m->Body( "Attachment Mail Testing.");
$m->Priority(3);
$m->Attach("email/".$file3);
ဒီေနရာမွာ attachment ကို create လုပ္တာျဖစ္ပါတယ္။ mail lib ထဲမွာ attach ဆိုတဲ့ function ရွိပါတယ္။ အဲဒီ function ကေနျပီး
_build_attachement ဆိုတဲ့ function ကိုျပန္ေခၚတာ ျဖစ္ပါတယ္။ အဲဒီ function ထဲမွာ file object ကိုသုံးျပီး attach လုပ္မယ့္ file
ကို split လုပ္တာေတြ႔ ရပါလိမ့္မယ္။
$m->Send(); // send the mail
အဲဒီ lib ထဲမွာ တစ္ျခား mail နဲ႔ ဆိုင္တဲ့ function ေတြေတာ္ေတာ္မ်ားမ်ားရွိပါတယ္။ download လုပ္ျပီး ၾကည့္လို႔ ရပါတယ္။
ဒီ post မွာကြၽန္ေတာ္ ေရးထားသလိုလုပ္ၾကည့္ျပီး မရရင္ ျပန္ေျပာေလ။ ေရးထားတာ မရွင္းရင္ေတာ့ ကြၽန္ေတာ္ အျပစ္ပါ ခင္ဗ်ား။
-
2009-11-01 15:11:57 |SAdministrator| admin - RE: Zayar Kyaw
Please read at here:
http://www.thadarphyu.net/joomzack/index.php?option=com_content&task=v iew&id=160&Itemid=1
-
2010-01-06 10:40:16 |203.81.166.xxx| aung myin - php attachment file send
please write sample form and php file.
I am still trying for the php , I cann't handle many of funchiton of php. please write sample html form and php script to download. so that we can be more understand than now.
thz bro
| < Prev | Next > |
|---|
Login Form
Latest Post
Categories Table View
- Reader's Conner (133)
- PHP (48)
- Joomla CMS (46)
- Codeigniter (18)
- jQuery (12)
- iDhamma (11)
- Mobile Development (10)
- PHP & AJAX (4)
- Apache (3)
- For Mac (3)
- mySQL (2)
- DhammaDroid (1)
I want to know
how to configure pdf libary .
I want pdf libary.
please