473,412 Members | 4,127 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,412 software developers and data experts.

using php mail to forward email?

Hello,

us**@x.com receives an email from us**@a.com. I want to forward that
email to us**@y.com. I want the contents/header to remain intact, with
the exception of adding "X-Forwarded-For". In other words, when
us**@y.com received the email, it will be from us**@a.com, but will
contain a reference that it was forwarded by us**@x.com.

I'm piping all email destined for us**@x.com to a php script. I've seen
some very complicated examples of using the mail function and I'm unsure
how to use the mail function to do what I need. I'm relatively new to
php so any advice is appreciated.

Thank you,
Craig.
#!/usr/local/bin/php -q
<?php

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

// forward it to us**@y.com
// ???
?>
Oct 14 '07 #1
15 15119
In our last episode, <9m*******************@news.indigo.ie>, the lovely and
talented Craig Hurley broadcast on comp.lang.php:
Hello,
us**@x.com receives an email from us**@a.com. I want to forward that
email to us**@y.com.
Why, exactly, don't you do that in your mail server? It's the right tool
for this job.

--
Lars Eighner <http://larseighner.com/ <http://myspace.com/larseighner>
Countdown: 463 days to go.
What do you do when you're debranded?
Oct 14 '07 #2
On Oct 14, 5:08 pm, Lars Eighner <use...@larseighner.comwrote:
In our last episode, <9mvQi.22601$j7.428...@news.indigo.ie>, the lovely and
talented Craig Hurley broadcast on comp.lang.php:
Hello,
u...@x.com receives an email from u...@a.com. I want to forward that
email to u...@y.com.

Why, exactly, don't you do that in your mail server? It's the right tool
for this job.

--
Lars Eighner <http://larseighner.com/ <http://myspace.com/larseighner>
Countdown: 463 days to go.
What do you do when you're debranded?

If I'm reading this correctly, it looks like he wants to be able to
spoof the email forward to look like the original sender sent it. I
think that if this is a legitimate question, if you aren't looking to
be, you will soon find yourself a SPAM hub. Essentially, you could
take an email from person1, change the contents, and send it to
another person with it looking like it came from person1.

Please don't provide an answer to this for the script kiddies trolling
usenet.

Oct 14 '07 #3
On 14/10/2007 22:08, Lars Eighner wrote:
Why, exactly, don't you do that in your mail server? It's the right tool
for this job.
There's more to what I'm planning to do than I included in my original
post. Rather than over complicate the original post, I've included only
the details that relate to my question regarding mail forwarding using php.

Regards,
Craig.
Oct 14 '07 #4
On 14/10/2007 22:56, ELINTPimp wrote:
If I'm reading this correctly, it looks like he wants to be able to
spoof the email forward to look like the original sender sent it. I
think that if this is a legitimate question, if you aren't looking to
be, you will soon find yourself a SPAM hub. Essentially, you could
take an email from person1, change the contents, and send it to
another person with it looking like it came from person1.

Please don't provide an answer to this for the script kiddies trolling
usenet.

j3sus_chr1st on a bike!

Rather than deliver mail directly to my inbox, I'm forwarding it to a
gmail account. gmail then kindly filters virus and spam. gmail then
forwards mail back the original email account, where it gets piped to my
php script.

The php script parses the email for a header which indicates that it's
been forwarded from a gmail account. If it finds that header which
gmail added, it delivers it to my inbox, otherwise, the mail gets
forwarded to gmail.

There are 2 reasons for doing this: 1) mail backup 2) extra antivirus
and antispam.

I didn't want to include these extra details because they're not really
relevant to my original question and would make it easier for people to
go off topic (how wrong I was!). Its great to see moral people out
there on the internet, but please don't jump the gun on a whim!!!

Now please, can we get back on topic: using php to forward email...

Regards,
Craig.
Oct 14 '07 #5
Craig Hurley wrote:
On 14/10/2007 22:56, ELINTPimp wrote:
>If I'm reading this correctly, it looks like he wants to be able to
spoof the email forward to look like the original sender sent it. I
think that if this is a legitimate question, if you aren't looking to
be, you will soon find yourself a SPAM hub. Essentially, you could
take an email from person1, change the contents, and send it to
another person with it looking like it came from person1.

Please don't provide an answer to this for the script kiddies trolling
usenet.


j3sus_chr1st on a bike!

Rather than deliver mail directly to my inbox, I'm forwarding it to a
gmail account. gmail then kindly filters virus and spam. gmail then
forwards mail back the original email account, where it gets piped to my
php script.

The php script parses the email for a header which indicates that it's
been forwarded from a gmail account. If it finds that header which
gmail added, it delivers it to my inbox, otherwise, the mail gets
forwarded to gmail.

There are 2 reasons for doing this: 1) mail backup 2) extra antivirus
and antispam.

I didn't want to include these extra details because they're not really
relevant to my original question and would make it easier for people to
go off topic (how wrong I was!). Its great to see moral people out
there on the internet, but please don't jump the gun on a whim!!!

Now please, can we get back on topic: using php to forward email...

Regards,
Craig.
Craig,

Lars is correct. You should do this in your mail server. You won't be
able to forward with PHP and keep the previous headers intact.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================

Oct 14 '07 #6
In our last episode,
<Dj*******************@news.indigo.ie>,
the lovely and talented Craig Hurley
broadcast on comp.lang.php:
On 14/10/2007 22:08, Lars Eighner wrote:
>Why, exactly, don't you do that in your mail server? It's the right tool
for this job.
There's more to what I'm planning to do than I included in my original
post. Rather than over complicate the original post, I've included only
the details that relate to my question regarding mail forwarding using php.
If you are doing some more than you said, then you are up to no good.

An honest person would do this in his mail server.
--
Lars Eighner <http://larseighner.com/ <http://myspace.com/larseighner>
Countdown: 463 days to go.
What do you do when you're debranded?
Oct 14 '07 #7
On 14/10/2007 23:38, Lars Eighner wrote:
If you are doing some more than you said, then you are up to no good.

An honest person would do this in his mail server.

Lars, please see my reply to ELINPimp.. what I'm trying to do is not a
basic forwarding rule.

I'm on shared hosting and I'm trying to do something a bit more advanced
than the hosting providers control panel provides for. They do however
allow users to pipe email to a script.

Is this newsgroup for discussing how to forward mail on a dedicated or
shared mail server? No.

Is this newsgroup for discussing php (including mail())? Yes.

Kindly stay on topic.

Regards,
Craig.
Oct 15 '07 #8
In our last episode,
<5_*******************@news.indigo.ie>,
the lovely and talented Craig Hurley
broadcast on comp.lang.php:
On 14/10/2007 23:38, Lars Eighner wrote:
>If you are doing some more than you said, then you are up to no good.

An honest person would do this in his mail server.

Lars, please see my reply to ELINPimp.. what I'm trying to do is not a
basic forwarding rule.
I read it. What you admit to is wanting to make google do your filtering
for you. Obviously you this is not just your personal mail, because you
wouldn't need forged headers for that. No you are obviously reselling
services and do not want your users to realize you are sending their mail
through googles filters and ripping off processing time from google for your
own profit.

--
Lars Eighner <http://larseighner.com/ <http://myspace.com/larseighner>
Countdown: 463 days to go.
What do you do when you're debranded?
Oct 15 '07 #9
On 15/10/2007 11:32, Lars Eighner wrote:
I read it. What you admit to is wanting to make google do your filtering
for you. Obviously you this is not just your personal mail, because you
wouldn't need forged headers for that. No you are obviously reselling
services and do not want your users to realize you are sending their mail
through googles filters and ripping off processing time from google for your
own profit.
Lars, you're funny. Do try to get a hold on your imagination. When
you're finished trying to get that imagination under control, have a
look at these:
http://www.google.ie/search?hl=en&q=...ter+spam&meta=

The very first link (from mboffin.com) is the most informative. It's
the process in that blog that I'm trying to replicate using a php
script. Unfortunately that particular bloggers site is down at the
moment, but it's a popular site so I'm sure it won't be long before it's
back up.

Finally, try to stay on topic please: using php mail to forward email?
I realise you may find this hard, what with your over-active imagination.

Have a nice day,
Craig.
Oct 15 '07 #10
On Oct 15, 3:46 am, Craig Hurley <s...@thehurley.comwrote:
On 15/10/2007 11:32, Lars Eighner wrote:
I read it. What you admit to is wanting to make google do your filtering
for you. Obviously you this is not just your personal mail, because you
wouldn't need forged headers for that. No you are obviously reselling
services and do not want your users to realize you are sending their mail
through googles filters and ripping off processing time from google for your
own profit.

Lars, you're funny. Do try to get a hold on your imagination. When
you're finished trying to get that imagination under control, have a
look at these:http://www.google.ie/search?hl=en&q=...ter+spam&meta=

The very first link (from mboffin.com) is the most informative. It's
the process in that blog that I'm trying to replicate using a php
script. Unfortunately that particular bloggers site is down at the
moment, but it's a popular site so I'm sure it won't be long before it's
back up.

Finally, try to stay on topic please: using php mail to forward email?
I realise you may find this hard, what with your over-active imagination.

Have a nice day,
Craig.
Hi Craig,

Have you made any progress on this? I'm interested in the same thing
-- and Lars is correct: it's totally for global domination purposes.

Actually, I'm also on a shared server and I want to be able to
simulate CPanel forwarders on-the-fly without having to login to
CPanel and setup each one of them. Not that it's at all important
what I want to do. I really wish that people could just focus on the
the specific question instead of giving advice and insinuation.

Thanks,
Dustin

Oct 23 '07 #11
In our last episode, <11**********************@q5g2000prf.googlegroups. com>,
the lovely and talented co*****@dustinbuss.com broadcast on comp.lang.php:
On Oct 15, 3:46 am, Craig Hurley <s...@thehurley.comwrote:
>On 15/10/2007 11:32, Lars Eighner wrote:
I read it. What you admit to is wanting to make google do your filtering
for you. Obviously you this is not just your personal mail, because you
wouldn't need forged headers for that. No you are obviously reselling
services and do not want your users to realize you are sending their mail
through googles filters and ripping off processing time from google for your
own profit.

Lars, you're funny. Do try to get a hold on your imagination. When
you're finished trying to get that imagination under control, have a
look at these:http://www.google.ie/search?hl=en&q=...ter+spam&meta=

The very first link (from mboffin.com) is the most informative. It's
the process in that blog that I'm trying to replicate using a php
script. Unfortunately that particular bloggers site is down at the
moment, but it's a popular site so I'm sure it won't be long before it's
back up.

Finally, try to stay on topic please: using php mail to forward email?
I realise you may find this hard, what with your over-active imagination.

Have a nice day,
Craig.
Hi Craig,
Have you made any progress on this? I'm interested in the same thing
-- and Lars is correct: it's totally for global domination purposes.
Actually, I'm also on a shared server and I want to be able to
simulate CPanel forwarders on-the-fly without having to login to
CPanel and setup each one of them. Not that it's at all important
what I want to do. I really wish that people could just focus on the
the specific question instead of giving advice and insinuation.
There is an honest way to do. The requirement on the problem that the
headers be forged makes insinuation unnecessary. People with honest
intentions do not need to forge headers.

--
Lars Eighner <http://larseighner.com/ <http://myspace.com/larseighner>
Countdown: 455 days to go.
What do you do when you're debranded?
Oct 23 '07 #12
Hey folks, interest reading here. Let me spice up the subject with my
question. I'm trying to link promoters in my area through my
website. So this is what I'm trying to do: User sends an email to
the promoter by clicking on the link on my website or a web form. The
the email comes to me, subject "promoter2" which will tell the email
to forward the email to promoter2 email address. Now, I want to
prevent the promoter to see the email address of the person that sends
it so they don't add them to their list and spam them later on. So
basically, the email to the promoter would come from my email address
with the question from the user. How about it?

Oct 23 '07 #13
ar*****@gmail.com wrote:
Hey folks, interest reading here. Let me spice up the subject with my
question. I'm trying to link promoters in my area through my
website. So this is what I'm trying to do: User sends an email to
the promoter by clicking on the link on my website or a web form. The
the email comes to me, subject "promoter2" which will tell the email
to forward the email to promoter2 email address. Now, I want to
prevent the promoter to see the email address of the person that sends
it so they don't add them to their list and spam them later on. So
basically, the email to the promoter would come from my email address
with the question from the user. How about it?

Your website is sending the mail. Just set the headers accordingly.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================

Oct 24 '07 #14
ar*****@gmail.com wrote:
Hey folks, interest reading here. Let me spice up the subject with my
question. I'm trying to link promoters in my area through my
website. So this is what I'm trying to do: User sends an email to
the promoter by clicking on the link on my website or a web form. The
the email comes to me, subject "promoter2" which will tell the email
to forward the email to promoter2 email address. Now, I want to
prevent the promoter to see the email address of the person that sends
it so they don't add them to their list and spam them later on. So
basically, the email to the promoter would come from my email address
with the question from the user. How about it?

I should add - if you're not using a mailto: link - but rather using PHP
to actually send the email.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================

Oct 24 '07 #15
co*****@dustinbuss.com wrote:
Hi Craig,

Have you made any progress on this? I'm interested in the same thing
-- and Lars is correct: it's totally for global domination purposes.

Actually, I'm also on a shared server and I want to be able to
simulate CPanel forwarders on-the-fly without having to login to
CPanel and setup each one of them. Not that it's at all important
what I want to do. I really wish that people could just focus on the
the specific question instead of giving advice and insinuation.

Thanks,
Dustin
Hi Dustin,
If your hosted on a server that runs exim and CPanel, there's an easy
way to implement this... have a read of this:
http://www.webpronews.com/blogtalk/2...lter-on-cpanel
I'm hosted on a server that runs exim and DirectAdmin, so the .forward
file doesn't work in the way outlined on that site--I'm limited to using
a .forward file for the real hosting package user (the account I use to
log into DA and SSH), any other email account is considered a virtual
user account, and the .forward file doesn't fire for those accounts.
http://www.directadmin.com/forum/arc...hp/t-4390.html

The above scenario means I would have to give out my real users email
address, and I don't want that. I want to be able to give out random
virtual email addresses, then when mail comes in, forward it onto gmail
(and its great spam filter) and gmail then forwards it back to another
of my virtual email accounts.
I have implemented it using a number of different forwarders to gmail
and back to my real user account. It's not quite the way I wanted it
(going to the real user account) but it works. I haven't had time to
dig deeper into emulating the .forward files by piping incoming email to
a php script; I hope to have a proper look before the year end.
Good luck.
Craig.
Oct 30 '07 #16

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

12
by: bonfils | last post by:
I believe this question has been asked before, but I haven't found the solution to it. I've given up on the php mail() function (doesn't work fast enough for sending large amounts of HTML...
12
by: Chuck Anderson | last post by:
Can anyone point me in the right direction? I want to use Php to automate confirmation of someone joining an email list by them replying to an email (so they don't have to have a browser?). I...
5
by: Eric Culus | last post by:
I seem to be having troubles with this page.... It's an automated mailing script... Steps: - system checks on x dates the variables linked to a maintenance contract (query on db) - when...
9
by: reshugoyal | last post by:
Hi, I need to implement Auto Updates in my application wherein I will be installing the application using msi. First time I will be installing it through CD.( Directly running the MSI file)...
2
by: Abhi | last post by:
i need to create a user in web mail using dotnet coad by using webmailserver api ex: xxx is my webmail then i want to create to a user in that webmail xxx ex: yyy@xxx.com how i should do in...
4
by: squishy | last post by:
I want to check an emailbox (that does not offer forwarding functions) and forward the mail in it to my new account. That's not a problem. But, I want the mails that I forward to my new email...
3
JohanK
by: JohanK | last post by:
Hi there, I need some help with exchange. One of the users that i have to add has multiple email addresses. So when adding the Active Directory User an exchange mail box is created for that...
1
by: creative1 | last post by:
When I test the application I get follwowing error: could not connect to smtp host: connection timeout error can someone please check if I have rigth settings? Where I am wrong here Is IP and...
3
by: shansivamani | last post by:
using SMTP to send email. is there any settings need to be configured apart from Host name and Port, while sending emails using SMTPClient in .Net? when i try to send mail to ids which has only...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.