Skip to content
Pakainfo

Pakainfo

Web Development & Good Online education

  • Home
  • Blog
  • Categories
  • Tools
  • Full Form
  • Guest Post
  • Advertise
  • About
  • Contact Us

php send mail attachment with Pear Mail

May 30, 2019 Pakainfo Programming, php Leave a comment

Today, We want to share with you php send mail attachment with Pear Mail.In this post we will show you php send email with attachment example, hear for php script to send email with attachment from form we will give you demo and example for implement.In this post, we will learn about write a program in php to send an email along with attachment with an example.

php send mail attachment with Pear Mail

There are the Following The simple About php send mail attachment with Pear Mail Full Information With Example and source code.

Free Live Chat for Any Issue

As I will cover this Post with live Working example to develop file attachment in php mail function, so the php send email with image attachment for this example is following below.

Read Also:  Get HTML source code of page with php - Scrape

PHP Add String To Pear Mail is an old version library but still in use some secure project by many for its some simplicity. includeing a PHP file attachment is good way to straightforward.

The PHP Script is in the best methods with parameter to ADD addAttachment.

index.php

    // fetch records from a database here.  This PHP code line will vary depending on your MySQL Database query method
    $member = $database->get_results( $sql, ARRAY_A);
    // create header member_csv_data row
    $member_csv_data = convertArrayToCsvData(array('First', 'Last', 'Title', 'Email', 'City', 'State'));
    // populate member_csv_data string
    foreach ($member as $person)
    	$member_csv_data .= convertArrayToCsvData($person);
    $crlf = "\n";
    $to = '[email protected]';
    $perlMailInfo["username"] = "[[email protected]@mailusername]";
    $perlMailInfo["password"] = "[[email protected]@mailpassword]";
    $perlMailInfo["host"] = "[smtpyourhost]";
    $perlMailInfo["port"] = "587";
    $perlMailInfo["auth"] = true;
    $headers = array("From" => "pakainfo <[email protected]>", 
    				 "Subject" => 'member Report',
    				 "Reply-To" => "[email protected]",
    				 "To" => $to
    );
     				 
     				 
    $body = 'We have ' . count($member) . ' in this report.'; 				
    // send email
    $mime = new Mail_mime($crlf);	 
    $mime->setTXTBody(strip_tags($body));
    $mime->setHTMLBody($body);
    // the magic is in the 4th parameter.  It tells addAttachment to treat $member_csv_data as a string, not a filename
    $mime->addAttachment($member_csv_data, 'text/csv', 'member-listings.csv', false);
    $body = $mime->get();
    $headers = $mime->headers($headers);
    $mail =& Mail::factory("smtp", $perlMailInfo); 
    $mail->send($to, $headers, $body);	 
    			
    function convertArrayToCsvData($fields, $delimiter = ",", $enclosure = '"', $escape_char = "\\")
    {
        $getCSV_DATA = fopen('php://temp', 'r+');
        fputcsv($getCSV_DATA, $fields, $delimiter, $enclosure, $escape_char);
        rewind($getCSV_DATA);
        $member_csv_data = fgets($getCSV_DATA);
        fclose($getCSV_DATA);
        return $member_csv_data;
    }


Angular 6 CRUD Operations Application Tutorials

Read :

  • Technology
  • Google Adsense
  • Programming
Read Also:  How to set limit and offset in Laravel Eloquent?

Summary

You can also read about AngularJS, ASP.NET, VueJs, PHP.

Download

I hope you get an idea about php send mail attachment with Pear Mail.
I would like to have feedback on my Pakainfo.com blog.
Your valuable feedback, question, or comments about this article are always welcome.
If you enjoyed and liked this post, don’t forget to share.

Pakainfo
Pakainfo

I am Jaydeep Gondaliya , a software engineer, the founder and the person running Pakainfo. I’m a full-stack developer, entrepreneur and owner of Pakainfo.com. I live in India and I love to write tutorials and tips that can help to other artisan, a Passionate Blogger, who love to share the informative content on PHP, JavaScript, jQuery, Laravel, CodeIgniter, VueJS, AngularJS and Bootstrap from the early stage.

Read Also:  php add minutes to datetime - PHP Add Minutes to Time Example

Related posts:

  1. PHP Mail Attachment – Php Send Email File-Images Attachments
  2. how to send attachment in mail in php?
  3. Mail send with attachment in php demo
  4. php send email with attachment example
  5. PHP Contact Form Send Email Add More File Attachment
  6. PHP Contact Form Send Email File Attachment Example
  7. Laravel Send Email Attachment Tutorial With Example
addattachment phpmailerfile attachment in php mail functionhow to send email with attachment using phpphp html email templatephp mail attachmentphp mail using gmail smtp tutorialphp script to send email with attachment from formphp send email with attachment examplephp send email with image attachmentphp send mail with pdf attachment examplephpmailerphpmailer htmlsmtp mail html formatsmtp mail with attachment in phpwrite a program in php to send an email along with attachment

Post navigation

Previous Post:PHP Get User IP Address
Next Post:Laravel 5.7 Delete Confirm Bootstrap jQuery Model

Search

Write For Us

We’re accepting well-written informative guest posts and this is a great opportunity to collaborate.
Submit a guest post to [email protected]
Contact Us

Freelance web developer

Do you want to build a modern, lightweight, responsive website quickly?
Need a Website Or Web Application Contact : [email protected]
Note: Paid Service
Contact Me

Categories

3movierulz (49) Ajax (464) AngularJS (377) ASP.NET (61) Bollywood (93) Codeigniter (175) CSS (98) Earn Money (61) Education (53) Entertainment (109) fullform (79) Google Adsense (62) Highcharts (77) Hollywood (94) JavaScript (1356) Jobs (39) jQuery (1422) Laravel (1086) LifeStyle (50) movierulz4 (48) Mysql (1029) Mysqli (890) Node.js (39) php (2116) Programming (2328) Python (96) ReactJS (37) Software (112) Software (81) Stories (87) tamilrockers (89) Tamilrockers kannada (49) Tamilrockers telugu (48) Tech (120) Technology (2372) Tips and Tricks (112) Tools (137) Top10 (338) Trading (56) Trending (54) VueJs (250) Web Technology (86) webtools (151) wordpress (165) World (165)

Advertise With Us

Increase visibility and sales with advertising. Let us promote you online.
Click Here

A To Z Full Forms

Access a complete full forms list with the meaning, definition, and example of the acronym or abbreviation.
Click Here
Cricday

  • Home
  • About Us
  • Terms And Conditions
  • Write For Us
  • Advertise
  • Contact Us
  • Youtube Tag Extractor
  • YouTube Monetization
  • Increase Domain Authority
  • Social Media Marketing
  • Freelance web developer
  • Tools
Pakainfo 9-OLD, Ganesh Sco, Kothariya Ring Road, Chokadi, Rajkot - 360002 India
E-mail : [email protected]
Pakainfo

© 2022 Pakainfo. All rights reserved.

Top
Subscribe On YouTube : Download Source Code
We accept paid guest Posting on our Site : Guest Post Chat with Us On Skype YouTube Tag Extractor