[X] Choose Font Here

PHP Attachment mail

ကြၽန္ေတာ္ေရးခဲ့ဘူးတဲ့ PHP Attachment Mail အေၾကာင္းကို ျပန္ေရးမယ္လို႔ စိတ္ကူးထားပါတယ္။ PHP မွာ Attachment မပါပဲ

mail send တာက လြယ္တယ္။ ဒီ function ေလးကိုေခၚျပီး parameter ေပးလိုက္႐ုံပါပဲ။


Syntax

ParameterDescription
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 မွာကြၽန္ေတာ္ ေရးထားသလိုလုပ္ၾကည့္ျပီး မရရင္ ျပန္ေျပာေလ။ ေရးထားတာ မရွင္းရင္ေတာ့ ကြၽန္ေတာ္ အျပစ္ပါ ခင္ဗ်ား။Smile

 

 

 

Comments (5)
  • Zayar Kyaw  - I want to know pdf libary

    I want to know
    how to configure pdf libary .
    I want pdf libary.

    please

  • 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

  • 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

  • Anonymous

    I'm not okay about with your php mail lib.
    I run at online..
    my browser shows this error.. :D
    ************
    Class Mail, method Mail : invalid address kyawswarthanmdy@gmail.com
    ******************
    pls, help me...

  • admin  - Re:

    Ok, Have you include mail library file like this?
    include "libmail.php";

Write comment
Your Contact Details:
Comment:
[b] [i] [u] [url] [quote] [code] [img]   
:D:angry::angry-red::evil::idea::love::x:no-comments::ooo::pirate::?::(
:sleep::););)):0
Security
Please input the anti-spam code that you can read in the image.

Login Form

Categories Table View

JoomlaWatch Stats 1.2.9 by Matej Koval

Facebook Share

Share on facebook

Accordion FAQ

mod_joomtouch

Version Iphone

Version Iphone by JoomTouch