Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8885335
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T21:17:05+00:00 2026-06-14T21:17:05+00:00

I am trying to use email piping with PHP. I have it working except

  • 0

I am trying to use email piping with PHP.

I have it working except I can’t get the ‘To’ field.

I am using the following PHP code:

#!/usr/bin/php -q
<?php

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

    $to1 = explode ("\nTo: ", $email);
    $to2 = explode ("\n", $to1[1]);
    $to = str_replace ('>', '', str_replace('<', '', $to2[0]));

}
fclose($fd);

mail('email@example.com','From my email pipe!','"' . $to . '"');

?>

If I use a email address (for example: john@smith.com) and send a email to my email address that is forwarded to my PHP piping script (pipe.php) I want it to be able to get who the email was sent to.

For Example:
john@smith.com emails my forwarding email that goes to my PHP piping script (bob@example.com) I want it to return just the bob part only without the @example.com

What happens now is that it returns the whole email address such as “bob@example.com” and I want it to only return bob (without any talking marks).

I have tried using this:

$to = $to.split("@");

but I seem to get an error that says: split() expects at least 2 parameters.
That gets sent to the person who sent the email.

Does anyone know how to do this or know what I might be doing wrong?

This is my first time using Piping in PHP, so if I am doing something wrong please let me know.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T21:17:06+00:00Added an answer on June 14, 2026 at 9:17 pm

    Ended up using:

    $to1 = explode ("\nTo: ", $email);
    $to2 = explode ("\n", $to1[1]);
    $to = str_replace ('>', '', str_replace('<', '', $to2[0]));
    list($toa, $tob) = explode('@', $to);
    

    then changed the mail to:

    mail('email@example.com','From my email pipe!','"' . $toa . '"');
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Trying to use a php generating the email address using the ID eg: peopleID
I am trying to use a database where the email can have multiple entries,
I am trying to use the below code to send email from asp.net(C#). using
I'm trying to use BCC fields in some PHP email. My code is as
so I'm trying to use PHP's mail() function to send an email when users
I have a database set up with email and password, I'm trying to use
I`m trying to send e-mail via c# and use the following code: public static
I'm trying to use mysql_real_escape_string() to secure a log in form. Using this code:
I am trying to use the PHP SMTP Email Validation library On line 163
Hi I am using razor and trying to use regular expression to validate email

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.