Slide môn học PHP session 8 handling email with PHP

17 6 0
  • Loading ...
1/17 trang

Thông tin tài liệu

Ngày đăng: 30/11/2016, 22:12

Handling Email with PHP Session 19 Review      Cookies provide us with the functionality of storing temporary Web user information Sessions enable Web sites store user requests and information on the Web Session library enables:  Creation  Serialization  Storage of session data php.ini file located under the usr/local/php4/lib directory Sessions enable PHP store user information on the Web server PHP / Session 19 / Slide of 17 Objectives   Send Mails Use attachments with mails PHP / Session 19 / Slide of 17 Email   Performs email sending process using the mail() function mail() function accepts three arguments Those are:      Recipient’s email address Subject of the email Body of the email Recipient’s email address is compulsory Other arguments are optional Local mail server for mail() function is specified in the php.ini configuration file PHP / Session 19 / Slide of 17 php.ini file  The section for mail function in the php.ini file look like: PHP / Session 19 / Slide of 17 Sending Email  Syntax for the mail() function is: mail(string to,string subject,string message [, string additional_headers]) Where,    string to – Specifies the receiver’s mail addresses string subject – Specifies the subject for the email 19 / Slide of 17 string message – Specifies the messages that willPHPbe/ Session written in the mail Sending email to a single user - I  For example, to send a mail using the mail() function Here, the mail is sent to john@bluemountain.com from tom@bluemountain.com PHP / Session 19 / Slide of 17 Sending email to multiple users I  For example, to send a mail to multiple recipients using mail() function Here, the mail is sent to all the users mentioned in the receiver’s list from samson@bluemountain.com PHP / Session 19 / Slide 10 of 17 Using attachment with email    An attachment is any text or graphics file sends with the email Uses an additional parameter, header, with the mail() function Syntax for the mail function with additional parameter is: mail(string to, string subject, string message [, string additional_headers[, string additional_parameters]]) Where,      string to – Specifies the receiver’s mail addresses string subject – Specifies the subject for the email string message – Specifies the messages that will be written in the mail string additional_headers – Specifies the mail sender’s address string additional_parameters – Specifies the headers those are set for attaching a file with the email PHP / Session 19 / Slide 11 of 17 Example for using attachment with email - I  For example, to send an email with an attachment [...]... subject for the email string message – Specifies the messages that will be written in the mail string additional_headers – Specifies the mail sender’s address string additional_parameters – Specifies the headers those are set for attaching a file with the email PHP / Session 19 / Slide 11 of 17 Example for using attachment with email - I  For example, to send an email with an attachment < ?php $file =... $subject, $body, $message, $header); PHP / Session 19 / Slide 13 of 17 Example for using attachment with email - III if($mail_send) { echo “To : $to   From : $from ”; echo “Subject : $subject”; echo “The attached file content :” echo $content; } else { echo “Mail could not be sent!!!”; } ?> PHP / Session 19 / Slide 14 of 17 Example for using attachment with email - IV     In this example,... made with the help of uniqid() function This function is used for assigning a unique identifier to the original mail The value of this function is assigned to the mime_boundary variable The content-type header indicates the type of message that is attached with the email PHP / Session 19 / Slide 15 of 17 Executing the codes  Execute the codes in the Mozilla Web browser The output appears as: PHP / Session. .. “MIME-VERSION: 1.0\r\n”; $header.=”Content-type: multipart/mixed”; PHP / Session 19 / Slide 12 of 17 Example for using attachment with email - II $header.= “boundary=\””.$mime_boundary.”\””; $message.=”Urgent Requirement.”; $message.=”\r\n\r\n”; $message.=”—“.$mime_boundary.”\r\n”; $message.=”Content-type:text/plain;charset=\“iso -88 591\”\r\n”; $message.=”—“.$mime_boundary.”\r\n”; $message.=“Content-Disposition:attachment;\r\n”;...Using attachment with email    An attachment is any text or graphics file sends with the email Uses an additional parameter, header, with the mail() function Syntax for the mail function with additional parameter is: mail(string to, string subject, string message [, string additional_headers[, string... Mozilla Web browser The output appears as: PHP / Session 19 / Slide 16 of 17 Summary      mail() function is the inbuilt function of PHP that is used for sending mails The implode() function is used for joining all the addresses present in the array with a comma operator A boundary is created in between the actual e-mail and the attachment with the help of the uniqid() function The base64_encode()... function is used for accepting the data in the form of a string and returns the data in the original form to the user The chunk_split() function is used for separating the data into smaller portions PHP / Session 19 / Slide 17 of 17
- Xem thêm -

Xem thêm: Slide môn học PHP session 8 handling email with PHP , Slide môn học PHP session 8 handling email with PHP , Slide môn học PHP session 8 handling email with PHP

Gợi ý tài liệu liên quan cho bạn

Nạp tiền Tải lên
Đăng ký
Đăng nhập