https://codesamplez.com/wp-content/cache/breeze-minification/js/breeze_b964594d3d957944241961017b9eb19bf02834de44cce93d8e67dd306852dbe346167181e455e33d5268ea01d973d77bb056848546f31794f31a4c31a9da5aa3.js
https://codesamplez.com/wp-content/cache/breeze-minification/js/breeze_23f1ae74c634d7e5e0a067c22b7a8c2d79c3ffd9a3b9395fc82c1b3b99635552b994f1f72f532f28ceaff1ea054ea026cd488cd62fa03a4ad91d212b5f3c5a72.js
https://codesamplez.com/wp-content/cache/breeze-minification/js/breeze_451c3884f51125f7687e5bb07cfab033c04cb7174c33f93213b2af4bad2af13cf48b92a7fa95fc86d7d436f355938a3ac50aa119cdb7c9b6d5a52815c3e6033e.js
https://codesamplez.com/wp-content/cache/breeze-minification/js/breeze_bfff9e63e857e9ee612e292d4a6edf3ced64d6a756925c953a9d8f77845ff601eca64d73dfa48756b1a9f4a4d6de6127a273bcde16ddeb71a22383460f4e94b0.js
https://codesamplez.com/wp-content/cache/breeze-minification/js/breeze_f4dd7e1d73ae5eda35ed5ad6aa965b612dbf483ece3ca50c1e8e30ad8dff1c66a160ed75e958e2db399661d229874783e0834ad813a479437035666b8e9e3386.js
https://codesamplez.com/wp-content/cache/breeze-minification/js/breeze_4fce0769137d4cd096989b0349bc3c2bbfca79ac311fdf714c41ab24d87551c7b49b756c8a8de090b0714a0ad0560e49fa532ba5a88875ea4afd78efac464df6.js
https://codesamplez.com/wp-content/cache/breeze-minification/js/breeze_85cec8b07d60426b11040e471babca0d2f9c8dc87a9b56e06cad39828f7f67179e29609100f282a574872c9a93fb635b25416300eb4c97bc5a653d00cf6f8dbf.js
https://codesamplez.com/wp-content/cache/breeze-minification/js/breeze_6768e5a27d4d357347338621c0d20bd269b126d30eec796193390f2f530fbaea60af84130c46f9786114be65149e661e87d55c339219c90aa76396d7e5b734ef.js
https://codesamplez.com/wp-content/cache/breeze-minification/js/breeze_2acd6bdff3b680341e8c727da5169a647123eb8fd0a90253161b4c3af272c15d293bf9bb217008bb13f84d1910b0e166798001f8603b6c026d5c20a76c41d47c.js
https://codesamplez.com/wp-content/cache/breeze-minification/js/breeze_e14386d947ca5729fab9739b1df30874ff6e96af8354f08d16ce3b58e2698c618366ba1fb4d7fe468f44d3c83b938defa96b7dfbaf0e3bbea3aa53dc9fca9192.js
https://codesamplez.com/wp-content/cache/breeze-minification/js/breeze_268c9bba6ba649318f0da28c37b09a9bbfa371210f9b6b52faa7fd8ae94abf6b3c3bfeb5df5705c93495ce1152ca58aeabc435d6c6c1bd959025165c3f50e086.js
  • Skip to main content
  • Skip to primary sidebar
  • Skip to footer
  • Home
  • Featured
    • Advanced Python Topics
    • AWS Learning Roadmap
    • JWT Complete Guide
    • Git CheatSheet
  • Explore
    • Programming
    • Development
      • microservices
      • Front End
    • Database
    • DevOps
    • Productivity
    • Tutorial Series
      • C# LinQ Tutorials
      • PHP Tutorials
  • Dev Tools
    • JSON Formatter
    • Diff Checker
    • JWT Decoder
    • JWT Generator
    • Base64 Converter
    • Data Format Converter
    • QR Code Generator
    • Javascript Minifier
    • CSS Minifier
    • Text Analyzer
  • About
  • Contact
CodeSamplez.com

CodeSamplez.com

Programming And Development Resources

You are here: Home / Programming / Parse Email with PHP: The Ultimate Guide

Parse Email with PHP: The Ultimate Guide

Updated May 12, 2025 by Rana Ahsan 21 Comments ⏰ 13 minutes

Parse Email With PHP

Ever wondered how those email-based systems actually work behind the scenes? You know, the ones where you send an email to a specific address and – like magic – it shows up on a website or triggers some action? I’ve had experience building such systems, and today I’m going to pull back the curtain and show you exactly how to parse email with PHP.

What You’ll Learn

In this comprehensive guide, I’ll walk you through:

  • Setting up email piping on your server (the absolute foundation)
  • Capturing raw email content with PHP (easier than you might think)
  • Breaking down emails into usable components (sender, subject, body)
  • Handling different email formats and clients (because Gmail isn’t the only one)
  • Extracting attachments (yes, we’ll cover that too!)
  • Real-world troubleshooting tips (from someone who’s faced these problems)

Let’s dive right in!

How Email Piping Works

Email piping is the backbone of email processing. It’s the mechanism that forwards incoming emails to your PHP script for processing. Here’s the basic flow:

  1. Someone sends an email to your designated address
  2. Your server receives this email
  3. Instead of just storing it, the server “pipes” it to your PHP script
  4. Your script processes the email content and does something useful with it

This process enables you to build powerful applications that react to email content – forums, ticketing systems, mailing lists, and much more.

Setting Up Email Forwarding to PHP

While this part doesn’t require coding, it’s crucial to get right. Most hosting providers offer this feature through cPanel or similar control panels.

Step-by-Step Setup

  1. Log into your hosting control panel (I’ll use cPanel as an example since it’s widely used)
  2. Locate the ‘Email’ section and find ‘Forwarders’ (or similar option)
  3. Click ‘Add Forwarder’ to create a new rule
  4. Choose the email address that will receive messages
  5. Select “Pipe to a Program” option
  6. Enter the path to your PHP script

This is where many beginners make mistakes. When entering the path to your script, remember:

  • You must use the server’s file path, NOT a URL
  • Include the PHP interpreter path at the beginning
  • Make sure your handler file has execute permissions

A proper command looks like this:

/usr/local/bin/php -q /home/yourdomain/public_html/handlers/email_parser.php

The -q flag suppresses HTTP headers, which is essential for proper processing.

Important Notes on Server Configuration

Not all hosting plans support email piping. If you don’t see this option, contact your hosting provider. Sometimes it’s available on higher-tier plans or can be enabled upon request.

I’ve personally set this up on many hosts including HostGator, BlueHost, SiteGround, and A2Hosting – they all support it, but sometimes with minor differences in configuration.

Reading Raw Email Content

Now that emails are being forwarded to your script, you need to capture their content. This requires a special directive at the very start of your file – before any PHP tags:

#!/usr/local/bin/php -q
<?php
// Your code starts hereCode language: PHP (php)

This “shebang” line tells the server to use the PHP interpreter. The path must match what you specified in the email forwarder.

Next, we need to read the raw email from standard input. Here’s the code:

$fd = fopen("php://stdin", "r");
$email_content = "";
while (!feof($fd)) {
    $email_content .= fread($fd, 1024);
}
fclose($fd);Code language: PHP (php)

This code opens PHP’s standard input stream, reads everything available, and stores it in the $email_content variable. Simple but effective!

Understanding Raw Email Format

At this point, you have the entire email captured in a string, but it’s not immediately usable. Raw emails include headers, content type information, boundaries for attachments, and more.

Here’s a simplified example of what you’ll see:

Return-path: <[email protected]>
Received: from mail-server.example.com ([192.168.1.1]:12345)
MIME-Version: 1.0
Date: Wed, 11 May 2025 14:32:01 +0600
Subject: Important information about your account
From: "John Doe" <[email protected]>
To: "Support Team" <[email protected]>
Content-Type: multipart/alternative; boundary=abc123

--abc123
Content-Type: text/plain; charset=UTF-8

This is the plain text version of the email.

--abc123
Content-Type: text/html; charset=UTF-8

<html>
<body>
<p>This is the <strong>HTML</strong> version of the email.</p>
</body>
</html>

--abc123--Code language: HTML, XML (xml)

It definitely looks messy – but don’t worry. We’ll parse it step by step.

Parsing Email Headers and Content

Now for the fun part – extracting useful information from this raw data. We’ll use a straightforward approach to separate headers from the body and then extract specific header values:

// Split email into lines
$lines = explode("\n", $email_content);

// Initialize variables
$from = "";
$to = "";
$subject = "";
$headers = "";
$message = "";
$is_header = true;

// Process line by line
foreach ($lines as $line) {
    // Check if we're still in the header section
    if ($is_header) {
        // Store all headers for reference
        $headers .= $line . "\n";
        
        // Extract specific headers
        if (preg_match("/^Subject: (.*)/i", $line, $matches)) {
            $subject = $matches[1];
        } elseif (preg_match("/^From: (.*)/i", $line, $matches)) {
            $from = $matches[1];
        } elseif (preg_match("/^To: (.*)/i", $line, $matches)) {
            $to = $matches[1];
        }
        
        // Empty line marks the end of headers
        if (trim($line) == "") {
            $is_header = false;
        }
    } else {
        // We're in the message body
        $message .= $line . "\n";
    }
}Code language: PHP (php)

This code loops through each line, collecting header information until it finds an empty line (which separates headers from the body). After that, it considers everything as the message body.

Working with Email Content Types

Real emails are more complex than our simple example. Most modern emails use MIME (Multipurpose Internet Mail Extensions) and include both plain text and HTML versions of the content, plus potentially attachments. Understanding them is crucial to parse email with PHP.

To properly handle these emails, we need to identify the content type and boundaries:

// Extract content type and boundary
$content_type = "";
$boundary = "";
if (preg_match('/Content-Type: (.*?);/i', $headers, $matches)) {
    $content_type = $matches[1];
    if (preg_match('/boundary="?(.*?)"?(\s|$)/i', $headers, $matches)) {
        $boundary = $matches[1];
    }
}

// For multipart emails, extract the parts
$message_parts = array();
if ($boundary && strpos($content_type, 'multipart/') === 0) {
    $parts = explode("--" . $boundary, $message);
    foreach ($parts as $part) {
        if (trim($part) != "" && $part != "--") {
            $message_parts[] = $part;
        }
    }
}Code language: PHP (php)

This code identifies whether the email is multipart (containing multiple formats) and extracts each part separately.

Extracting Plain Text and HTML Content

Now we can identify and extract specific content types from the email:

$plain_text = "";
$html_content = "";

foreach ($message_parts as $part) {
    // Check content type of this part
    if (preg_match('/Content-Type: text\/plain/i', $part)) {
        // Extract plain text after the first empty line
        $plain_text = preg_replace('/^.*?\r?\n\r?\n/s', '', $part);
    } elseif (preg_match('/Content-Type: text\/html/i', $part)) {
        // Extract HTML after the first empty line
        $html_content = preg_replace('/^.*?\r?\n\r?\n/s', '', $part);
    }
}

// If no parts were found, use the entire message as plain text
if (empty($message_parts) && trim($message) != "") {
    $plain_text = $message;
}Code language: PHP (php)

This gives us both the plain text and HTML versions of the email content, which you can use according to your application’s needs.

Extracting Email Attachments

Many applications need to handle email attachments. Here’s how to extract them:

$attachments = array();

foreach ($message_parts as $part) {
    // Check if this part has a filename (indicates attachment)
    if (preg_match('/Content-Disposition: attachment; filename="?(.*?)"?(\s|$)/i', $part, $matches)) {
        $filename = $matches[1];
        
        // Extract content type
        $attachment_type = "";
        if (preg_match('/Content-Type: (.*?);/i', $part, $matches)) {
            $attachment_type = $matches[1];
        }
        
        // Extract content transfer encoding
        $encoding = "";
        if (preg_match('/Content-Transfer-Encoding: (.*?)/i', $part, $matches)) {
            $encoding = trim($matches[1]);
        }
        
        // Extract content after headers
        $content = preg_replace('/^.*?\r?\n\r?\n/s', '', $part);
        
        // Decode content based on encoding
        if (strtolower($encoding) == 'base64') {
            $content = base64_decode($content);
        } elseif (strtolower($encoding) == 'quoted-printable') {
            $content = quoted_printable_decode($content);
        }
        
        // Store attachment info
        $attachments[] = array(
            'filename' => $filename,
            'type' => $attachment_type,
            'content' => $content
        );
    }
}Code language: PHP (php)

Now you can save these attachments to disk or process them in memory.

Handling Character Encoding Issues

Email clients can use various character encodings, leading to issues with special characters. Here’s how to handle common encoding problems:

// Handle quoted-printable encoding in subject
if (preg_match('/=\?UTF-8\?Q\?(.*?)\?=/i', $subject, $matches)) {
    $subject = quoted_printable_decode(str_replace('_', ' ', $matches[1]));
}

// Handle character encoding in message body
if (preg_match('/charset="?(.*?)"?(\s|$)/i', $headers, $matches)) {
    $charset = $matches[1];
    if (strtolower($charset) != 'utf-8') {
        // Convert to UTF-8 if possible
        if (function_exists('mb_convert_encoding')) {
            $plain_text = mb_convert_encoding($plain_text, 'UTF-8', $charset);
            $html_content = mb_convert_encoding($html_content, 'UTF-8', $charset);
        }
    }
}Code language: PHP (php)

This handles the most common encoding issues you’ll encounter, especially with non-English content.

Complete Working Example

Let’s put it all together in a complete script:

#!/usr/local/bin/php -q
<?php
// Log file for debugging
$log_file = '/path/to/email_log.txt';

// Read email from stdin
$fd = fopen("php://stdin", "r");
$email_content = "";
while (!feof($fd)) {
    $email_content .= fread($fd, 1024);
}
fclose($fd);

// Log the raw email for debugging
file_put_contents($log_file, date('Y-m-d H:i:s') . " - Raw Email:\n" . $email_content . "\n\n", FILE_APPEND);

// Split email into lines
$lines = explode("\n", $email_content);

// Initialize variables
$from = "";
$to = "";
$subject = "";
$headers = "";
$message = "";
$is_header = true;

// Process line by line
foreach ($lines as $line) {
    if ($is_header) {
        $headers .= $line . "\n";
        
        if (preg_match("/^Subject: (.*)/i", $line, $matches)) {
            $subject = $matches[1];
        } elseif (preg_match("/^From: (.*)/i", $line, $matches)) {
            $from = $matches[1];
        } elseif (preg_match("/^To: (.*)/i", $line, $matches)) {
            $to = $matches[1];
        }
        
        if (trim($line) == "") {
            $is_header = false;
        }
    } else {
        $message .= $line . "\n";
    }
}

// Extract content type and boundary
$content_type = "";
$boundary = "";
if (preg_match('/Content-Type: (.*?);/i', $headers, $matches)) {
    $content_type = $matches[1];
    if (preg_match('/boundary="?(.*?)"?(\s|$)/i', $headers, $matches)) {
        $boundary = $matches[1];
    }
}

// For multipart emails, extract the parts
$message_parts = array();
$plain_text = "";
$html_content = "";

if ($boundary && strpos($content_type, 'multipart/') === 0) {
    $parts = explode("--" . $boundary, $message);
    foreach ($parts as $part) {
        if (trim($part) != "" && $part != "--") {
            // Check content type of this part
            if (preg_match('/Content-Type: text\/plain/i', $part)) {
                $plain_text = preg_replace('/^.*?\r?\n\r?\n/s', '', $part);
            } elseif (preg_match('/Content-Type: text\/html/i', $part)) {
                $html_content = preg_replace('/^.*?\r?\n\r?\n/s', '', $part);
            } elseif (preg_match('/Content-Disposition: attachment/i', $part)) {
                // Process attachment if needed
                // ...
            }
        }
    }
} else {
    // Not multipart, use entire message as plain text
    $plain_text = $message;
}

// Do something with the extracted data
// For example, store in database:
$db = new PDO('mysql:host=localhost;dbname=your_database', 'username', 'password');
$stmt = $db->prepare("INSERT INTO emails (sender, subject, text_content, html_content, received_at) 
                      VALUES (:sender, :subject, :text, :html, NOW())");
$stmt->execute([
    'sender' => $from,
    'subject' => $subject,
    'text' => $plain_text,
    'html' => $html_content
]);

// Log the processed information
$log_message = date('Y-m-d H:i:s') . " - Processed Email:\n";
$log_message .= "From: $from\nSubject: $subject\n";
$log_message .= "Plain Text: " . substr($plain_text, 0, 100) . "...\n\n";
file_put_contents($log_file, $log_message, FILE_APPEND);Code language: PHP (php)

Advanced Tips for Working with Parsed Emails

1. Security Considerations

When processing emails, always remember they come from an external source, making them potential security risks:

// Sanitize data before using in HTML context
$safe_subject = htmlspecialchars($subject, ENT_QUOTES, 'UTF-8');
$safe_from = htmlspecialchars($from, ENT_QUOTES, 'UTF-8');

// Use prepared statements for database operations
// (as shown in the complete example)Code language: PHP (php)

2. Debugging Email Processing

Email processing can be tricky to debug since you can’t just reload a page to test it. Create a robust logging system:

function log_email_processing($message, $data = null) {
    $log_file = '/path/to/email_logs/debug_' . date('Y-m-d') . '.log';
    $log_entry = date('Y-m-d H:i:s') . " - $message";
    
    if ($data !== null) {
        $log_entry .= "\n" . print_r($data, true);
    }
    
    file_put_contents($log_file, $log_entry . "\n\n", FILE_APPEND);
}

// Usage:
log_email_processing("Processing started");
log_email_processing("Extracted headers", $headers);Code language: PHP (php)

3. Handling Different Email Clients

Different email clients format emails differently. Test your parser with various clients:

// Detect email client from headers
$email_client = "unknown";
if (strpos($headers, 'X-Mailer: Microsoft Outlook') !== false) {
    $email_client = "outlook";
    // Apply Outlook-specific parsing adjustments
} elseif (strpos($headers, 'User-Agent: Mozilla/5.0') !== false && 
          strpos($headers, 'Thunderbird') !== false) {
    $email_client = "thunderbird";
    // Apply Thunderbird-specific parsing adjustments
}Code language: PHP (php)

Common Issues and Their Solutions

Issue 1: Special Characters Appearing as Gibberish

This is usually an encoding issue. Make sure you’re properly handling character encodings:

// For quoted-printable encoded text (common in emails)
$plain_text = quoted_printable_decode($plain_text);

// Then ensure UTF-8 encoding
if (function_exists('mb_convert_encoding')) {
    $plain_text = mb_convert_encoding($plain_text, 'UTF-8', 'AUTO');
}Code language: PHP (php)

Issue 2: Line Breaks in Email Body

Email line breaks can be problematic:

// Normalize line breaks
$plain_text = str_replace(["\r\n", "\r"], "\n", $plain_text);

// For HTML content display
$html_for_display = nl2br($plain_text);Code language: PHP (php)

Issue 3: Duplicate Email Processing

Sometimes your script might process the same email multiple times:

// Generate a unique email ID based on content
$email_id = md5($from . $subject . substr($message, 0, 100) . time());

// Check if this email was already processed
$stmt = $db->prepare("SELECT id FROM processed_emails WHERE email_id = ?");
$stmt->execute([$email_id]);
if ($stmt->rowCount() > 0) {
    // Already processed this email, exit
    exit;
}

// Mark as processed
$db->prepare("INSERT INTO processed_emails (email_id, processed_at) VALUES (?, NOW())")
   ->execute([$email_id]);Code language: PHP (php)

Conclusion

Parsing email with PHP is an incredibly powerful technique that opens up many possibilities for web applications. Whether you’re building a forum system, a support ticket platform, or just automating your workflow, understanding how to process incoming emails is an essential skill.

Remember, the key points are:

  1. Set up proper email forwarding to your PHP script
  2. Capture the raw email content
  3. Parse the headers and body into usable components
  4. Handle different content types and encodings
  5. Implement proper logging for debugging

I hope this guide has given you a solid foundation on how to parse email with PHP. The examples provided should work across most hosting environments and with most email clients.

What will you build with this knowledge? Let me know in the comments!

FAQ: Parsing Email with PHP

Q: Can I use this technique with shared hosting?

A: Absolutely! Most shared hosting providers support email piping. Just make sure to use the correct paths for your specific host.

Q: How do I handle email attachments larger than my PHP memory limit?

A: You can stream attachments directly to disk instead of loading them into memory:

// When processing an attachment
$tmp_file = tempnam(sys_get_temp_dir(), 'email_attachment_');
file_put_contents($tmp_file, $attachment_content);
// Process the file on disk instead of in memoryCode language: PHP (php)

Q: Does this work with modern PHP versions?

A: Yes, the techniques shown work with PHP 7.x and PHP 8.x. For older PHP versions (5.x), you might need to adjust some syntax.

Q: How can I test my email parsing without sending actual emails?

A: Save some sample raw emails to text files, then simulate the piping process:

bashcat sample_email.txt | php -q your_handler.php

Q: How do I handle email replies and maintain conversation threads?

A: Extract and store the Message-ID header from incoming emails. For replies, look for the In-Reply-To header which contains the Message-ID of the original email.

Share if liked!

  • Click to share on Facebook (Opens in new window) Facebook
  • Click to share on X (Opens in new window) X
  • Click to share on LinkedIn (Opens in new window) LinkedIn
  • Click to share on Pinterest (Opens in new window) Pinterest
  • Click to share on Reddit (Opens in new window) Reddit
  • Click to share on Tumblr (Opens in new window) Tumblr
  • Click to share on Pocket (Opens in new window) Pocket

You may also like


Discover more from CodeSamplez.com

Subscribe to get the latest posts sent to your email.

First Published On: December 22, 2011 Filed Under: Programming Tagged With: php

About Rana Ahsan

Rana Ahsan is a seasoned software engineer and technology leader specialized in distributed systems and software architecture. With a Master’s in Software Engineering from Concordia University, his experience spans leading scalable architecture at Coursera and TopHat, contributing to open-source projects. This blog, CodeSamplez.com, showcases his passion for sharing practical insights on programming and distributed systems concepts and help educate others.
Github | X | LinkedIn

Reader Interactions

Comments

  1. sunil kumar says

    October 11, 2012 at 11:48 PM

    Thanks for your good solution.

    Reply
  2. Rob Chadwick says

    May 11, 2013 at 6:23 PM

    Thanks! This was very useful.

    Reply
  3. Stewart says

    September 5, 2013 at 12:44 PM

    Very good, thanks.

    I added an insert statement to drop the data from the email message including email address etc into a MySQL DB – but I get a bunch of unwanted stuff in the database appearing in the ‘message’ column which looks like headers of the email like this:

    “This is a multi-part message in MIME format.

    ——=_NextPart_000_0101_01CEAA6E.6A79E160
    Content-Type: text/plain;
    charset=”iso-8859-1”
    Content-Transfer-Encoding: quoted-printable

    I also see quotes appearing in the other columns – how to get rid of any unwanted characters?

    Reply
    • Md Ali Ahsan Rana says

      September 30, 2013 at 1:36 PM

      You will need to filter them with regular expression as far I can suggest. Don’t see any other way around atm, email contents usually do have such lots of unnecessary characters for formatting probably, which differs from client to client(yahoo/gmail/outlook etc).

      Reply
  4. alby says

    October 31, 2013 at 6:15 PM

    I have my text in spanish but when I answer the mail with outlook, I get unwanted characters where I use spanish accents á ú í é ó and in the line breack I get =20, can you give me a hint on how can I replace this charaters with the vocals and with the accent again ?
    thanks for your help

    Reply
  5. AATIF says

    November 2, 2013 at 3:11 AM

    NICE OWRK

    Reply
  6. Alex Whyatt says

    January 26, 2014 at 1:30 PM

    Hello! I know this post is a little bit cold… but I wonder if you might help? I have implemented this code, and it works with one exception… each time a mail is successfully parsed i get 7 mails.

    The processing i have programmed is supposed to identify the subject, and then add that as the body of a mail to my office email address.

    only I get 7 identical emails!

    Any thoughts or direction would be much appreciated!

    cheers
    LAex

    Reply
  7. Ashok Singh says

    August 29, 2014 at 3:17 AM

    Hi ,

    Thanks for the post. It’s realy useful. I have implement this functionality and It’s working fine.
    Regards,
    Ashok Singh

    Reply
  8. Tshepo says

    October 11, 2014 at 11:32 PM

    Hi,

    How can I use this to also retrieve attachments from the email?

    Regards,

    Reply
  9. krishnalal says

    February 26, 2015 at 10:01 PM

    How can add forwaders path to capanel in framework codeigniter

    Reply
    • Md Ali Ahsan Rana says

      February 27, 2015 at 1:53 PM

      You can put something like “/path/to/domain/index.php/controller/method” easily to get it working. Just imagine, .htaccess won’t have any effect as this is not going through Apache server, rather direct access.

      Reply
  10. Esayed says

    June 1, 2015 at 7:22 AM

    I have implemented the script and it is working fine. The only issue is that I am trying to send an email back to the sender with an output text file of the parsed info as an attachment. The output text file looks good, however the sender is receiving the email without the attachment.
    Is it possible to send an attachment email from the script itself since the sending email part with attachment works when executed separately ?

    Reply
  11. parthpabariParth says

    September 14, 2015 at 4:10 AM

    how to get attachments files??

    Reply
  12. Robert says

    June 10, 2017 at 5:53 AM

    Is it possible to pipe emails of a gmail account?
    Thank you

    Reply
    • Naveed Fakhar says

      May 16, 2023 at 2:52 PM

      first of all forword gmail to privet email where forword command existed then you will get, if you want dirctilly its log procedure

      Reply
  13. dany says

    February 16, 2018 at 1:14 AM

    How to get exact messages and images? let me know..

    Reply
  14. Aagii says

    February 29, 2020 at 4:50 PM

    How can I pipe to Laravel Controller? Please, help.

    Reply
  15. Tarek O says

    March 16, 2020 at 5:25 PM

    It did not work for me

    Reply
    • ld13 says

      June 11, 2020 at 7:52 AM

      What did not work for you? Need something more verbose to assist…

      Reply
  16. John Hoskinson says

    October 15, 2020 at 4:45 PM

    Thank you for this. It worked great for me except I can’t figure out why I can’t write any of the details to a file. I’m guessing that maybe there’s something unexpected with the file path? My script is in public_html/my_folder/pipescript.php and I’m trying to write in to a text file in public_html/my_folder/files/

    so I have a code like this:

    $File = “files/text-file.txt”;
    $Open = fopen($File, “a+”);
    fwrite($Open, “$message”);
    fclose($Open);

    I send a test email, I get the message back in the body as expected, but nothing writes to the file.

    Any suggestions?

    Reply
  17. Jaydip Shingala says

    August 8, 2022 at 1:48 PM

    Hello, It resolved my problem.
    Thanks

    Reply

Leave a ReplyCancel reply

Primary Sidebar

  • Facebook
  • X
  • Pinterest
  • Tumblr

Subscribe via Email

Top Picks

python local environment setup

Python Local Development Environment: Complete Setup Guide

In-Depth JWT Tutorial Guide For Beginners

JSON Web Tokens (JWT): A Complete In-Depth Beginners Tutorial

The Ultimate Git Commands CheatSheet

Git Commands Cheatsheet: The Ultimate Git Reference

web development architecture case studies

Web Development Architecture Case Studies: Lessons From Titans

static website deployment s3 cloudfront

Host Static Website With AWS S3 And CloudFront – Step By Step

Featured Dev Tools

  • JWT Decoder
  • Diff Checker

Recently Published

service worker framework integration

Service Workers in React: Framework Integration Guide

service worker caching strategies

Service Worker Caching Strategies: Performance & Offline Apps

service worker lifecycle

Service Worker Lifecycle: Complete Guide for FE Developers

what is service worker

What Is a Service Worker? A Beginner’s Guide

Dynamic Typing In Python

Dynamic Typing in Python: A Comprehensive Guide For Beginners

Footer

Subscribe via Email

Follow Us

  • Facebook
  • X
  • Pinterest
  • Tumblr

Explore By Topics

Python | AWS | PHP | C# | Javascript

Copyright © 2025

https://codesamplez.com/wp-content/cache/breeze-minification/js/breeze_17d16ecb9cbc5c6c8212c772791fb7dd1823c2f3ee7a55ae7ef35186f2d7fa3b2782690661654076bc878b03f6e48190dc8c4c6b8843d0b8a35f12203b1fa4a4.js
https://codesamplez.com/wp-content/cache/breeze-minification/js/breeze_c402e38f1879c18090377fb6b73b15ac158be453ecda3a54456494fe8aba42b990c293bae5424e5643d52515ffc2067e0819995be8d07d5bba9107a96780775c.js
https://codesamplez.com/wp-content/cache/breeze-minification/js/breeze_ffc3511227531cc335353c54c3cbbaa11d0b80e5cb117478e144436c13cd05495b67af2e8950480ed54dbdabcdcef497c90fdb9814e88fe5978e1d56ce09f2cf.js
https://codesamplez.com/wp-content/cache/breeze-minification/js/breeze_d57da9abfef16337e5bc44c4fc6488de258896ce8a4d42e1b53467f701a60ad499eb48d8ae790779e6b4b29bd016713138cd7ba352bce5724e2d3fe05d638b27.js
https://codesamplez.com/wp-content/cache/breeze-minification/js/breeze_edc0e9ef106cc9ef7edd8033c5c6fcff6dc09ee901fd07f4b90a16d9345b35a06534f639e018a64baaf9384eee1df305570c1ecad747f41b787b89f53839962b.js
https://codesamplez.com/wp-content/cache/breeze-minification/js/breeze_bc2182bb3de51847c8685df18692deda654dbf90fb01b503eb1bb0b68b879a051b91f30a9210ed0b2ba47c730db14b159cd9391ffdcd7117de397edd18366360.js
https://codesamplez.com/wp-content/cache/breeze-minification/js/breeze_dccc492dbbfdac33d1411f9df909e849c7268fcf99b43007f278cde3a0adc0ae00e8cae5ec81cf255b9a6eae74e239ba1fa935572af77173219cb081f7d2327d.js
https://codesamplez.com/wp-content/cache/breeze-minification/js/breeze_00bacf9e36181aac2b666d110cd9d82257f846766e7041b2d7b3c909b458982931ccc9b203e37098fbdfcf43ca359cf04e3824a724a6789fc204196d3a72ad29.js
https://codesamplez.com/wp-content/cache/breeze-minification/js/breeze_72f0b62bed031ab40ba0732e51c1482fae942c3f12daad4527211dfb7ee662854d62bb9a0ff7309f7c871a3fb3a754dd50c231d8778d644045da26abc2e3b419.js
https://codesamplez.com/wp-content/cache/breeze-minification/js/breeze_aa5a5d229b421633f4247380e1e8c0a4854f82efb35d13a5b07b7b8fbe22e98842a580f063e5965345a51c477a7f5c2585edf8dd7d896b2438dc61f91d8d970c.js
https://codesamplez.com/wp-content/cache/breeze-minification/js/breeze_bb8058a9e234a7ffaa98891b1df7f6b8e67410e6984568b151daa05113b8c7f89d7b5918ae73f020998a16f7f5a087a13d6a9a5e5d7c301e2ca12fd9d1f8d177.js
https://codesamplez.com/wp-content/cache/breeze-minification/js/breeze_647fb67570c6108fb10ae6785a1abdbecac99ffcf80351d0bef17c3cf783dce497b1895fcdaae997dacc72c359fbfb128cc1540dd7df56deb4961e1cd4b22636.js
https://codesamplez.com/wp-content/cache/breeze-minification/js/breeze_f7a298a0f1f754623fe3b30f6910ce2c1373f715450750bd7a391571812b00df1917e2be90df6c4efc54dbdfda8616278a574dea02ba2c7a31992768df8db334.js
https://codesamplez.com/wp-content/cache/breeze-minification/js/breeze_df30604d5842ef29888c3c1881220dc6d3f8854666d94f0680c5f38aa643c5fb79b10eb9f10998d8856eb24ca265783195937434fd6c2bb8e4846df0277a7fb7.js
https://codesamplez.com/wp-content/cache/breeze-minification/js/breeze_f17fe6fb0993f1703181d7ae9e9ea570f3d33a43afd6f2a4567daa1a6745698c7b8193dc72d50991d2dd87cd3dcf663959206607d193a9b57926d061a1f50aef.js
https://codesamplez.com/wp-content/cache/breeze-minification/js/breeze_945dcbab2c2a131f3c90f4fb91776b76066d589f84fb55bff25cd5d79a56218000616bfca1f0af9a74f32348693707af49e8fe624de8aa34f1e1c5b6a25709cf.js
https://codesamplez.com/wp-content/cache/breeze-minification/js/breeze_65820d252e1b93596de6697fd5f02483f3e2524a0696c7d698b64745edb32bf5831a90e556842f5f88c8209766cc78ca3a41cf783d20236a9f90d4a7ea7b3e72.js
https://codesamplez.com/wp-content/cache/breeze-minification/js/breeze_7286884797a1210857e2a36f8ab46604b0034b6abf512380447a5763c873db6a72b8547f660053de0ea69faef1eb64878f39ff4b0ea86c963efab95764a3bf5b.js
https://codesamplez.com/wp-content/cache/breeze-minification/js/breeze_cbcf6c279ac6c6a25ae138bf964e64a5fd90d22dcdf8a53b6fe7b72cefa51063bfb0181a6e50dd2acdcae2795619887d1d83b10461e44e5103be756f2588d837.js
https://codesamplez.com/wp-content/cache/breeze-minification/js/breeze_47965bc586b95810c925b9df3314e0c9a5cd121e70ca0831f87df0bc034695de4f83ecf2def86f737e14614ee138794473cf32cd3082a5d38db9dec0c1f266fa.js
https://codesamplez.com/wp-content/cache/breeze-minification/js/breeze_12aa201cea075846d266536aa222d64d4088b851d87f55dac5e611b77add6826c8ebc6e82650fcd1a9e88a05a0072dedd195719c5f64cd4580a0acd8aee05d92.js
https://codesamplez.com/wp-content/cache/breeze-minification/js/breeze_eaa93529c38925eb07368c361382956fbd910b5106b8589fa7e2e15a59c46437de3698d50ec4754bc45e6dfac47b3f41cc4c6112d7ede071ca8950385d4987dc.js
https://codesamplez.com/wp-content/cache/breeze-minification/js/breeze_3fccd94449a5bded281f8f9d716a232f5adc939b90ccd78d0cca3903112444ce5129c3beb9bd6b836200ab45ee1f515e62283ea5b0bdb3b6174232cc781ba3cb.js
https://codesamplez.com/wp-content/cache/breeze-minification/js/breeze_d87ea86dd0e7ecdd5fe7a5bb67becf943e57c3add866b456034d51663d099031bd563e12f61fdccc044969adf938a8584ed22ccd401ab8b669e20e4f92fb54e8.js
https://codesamplez.com/wp-content/cache/breeze-minification/js/breeze_35311c3d71a3605fad4e1d6b50f3911311cdcc46418bdf56d6d0308a75a69585269ee7582a335e29989adf308fa1a81a10a2c2d4e257e9d680447a4996f6269e.js
https://codesamplez.com/wp-content/cache/breeze-minification/js/breeze_f4fc182ef03c12e9dcadd6febc3dbaa4a29134469057ca9e8ec0be2f2de29a494514ff4b59798e74debf26f78b2df2b3e2665c69b77035761fb463b783202915.js
https://codesamplez.com/wp-content/cache/breeze-minification/js/breeze_85c0f2769456e60153b0fd8364b82a035da53384f62de342d9bdca806f3f1ea56486919a00497a18d457949c82bf8bfacc4423fc332074ddf71a49a8fe628fff.js
https://codesamplez.com/wp-content/cache/breeze-minification/js/breeze_67f99bef3678c549a14b5f2ff790cce6aba338dca29020755444231b45fa0f980f795e3658496ba70739a099b47b22bc2eab564343ac6132309de3adbbae3455.js
https://codesamplez.com/wp-content/cache/breeze-minification/js/breeze_09eecfdd96206ed13830b4b93cfb2cc75cd38083671a34194437b5734b5bb38712209dc335b07e3266ceb3c3a44a155b9bbe5f3e0e1105b19dd45d3def76f020.js
https://codesamplez.com/wp-content/cache/breeze-minification/js/breeze_4c089fbdb88e3b624a6f884d3ba1bf606f003bfcd3742376d0d353cd62181dc663aa3811a56361c3100de488fc4d6595a50de2b26f058921ba74f5f2c1b5be00.js
https://codesamplez.com/wp-content/cache/breeze-minification/js/breeze_897ff6ac314c5f5e0f496c6af624bd9abf296a02cb5aeb850b9220b6dc3ce2fc4004cb02ed8b59d59d4b9c9d90f050d6eebc1d08ecaebab2f671f7d9367e6410.js
https://codesamplez.com/wp-content/cache/breeze-minification/js/breeze_67d1e619e71d36ae00ddcf85ee18628bb4eb64fcb3d6119b463e75cb987013420a21136d19cd03e6634ccc01cfa9af4a357930e4cf6900953b7812efb4f249fb.js