473,749 Members | 2,411 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 15234
In our last episode, <9m************ *******@news.in digo.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...@larseig hner.comwrote:
In our last episode, <9mvQi.22601$j7 .428...@news.in digo.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*******@attgl obal.net
=============== ===

Oct 14 '07 #6
In our last episode,
<Dj************ *******@news.in digo.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.in digo.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

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

Similar topics

12
3915
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 mails). Instead, I'd like to throw all my mails into the mail queue. I'm running sendmail on freeBSD and imagine that I should be able to use the exec() command.
12
8797
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 will probably use a hyperlink with a unique ID, but I also want to know how to go about reading from a mailbox with Php so I can use an email reply method, too. I'm having trouble finding any kind of tutorial. From the bit of searching I've done,...
5
1786
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 variable matches given element is queries the db again to retrieve the contact data linked to the maintenance system - I then sends an email to the different contacts linked to that
9
1751
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) Next time any of my clients run the application and if newer version is available(which has to be specified on server) they must get a notification that "New version is available. Do you want to Download/Install?" and depending on the user action if...
2
2656
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 dotnet code plz.... help me
4
1656
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 account to look and act like they came from the original sender (i.e. when I click reply, I want the original senders address in my Outlook's "To" field). How do I send these messages as though they came from the original sender?
3
3217
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 specific user name. Now the question is how do I forward the emails from the other addresses to that one without creating more AD users because I don't have enough CALs. So in short I have User1 with email address User1@domain.com, but User1 also...
1
1790
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 mail host setting ok or not? Contactus.jsp <!doctype html public "-//W3C//DTD HTML 4.0 Transitional//EN//"> <html>
3
1787
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 one dot in the domain name (eg : test@abc.com) there are no issues. but when the mail ids are like (test@abc.co.in or test@abc.rr.com) the mail is not getting received by those ids. also, there are no exceptions occured when i debugged it.
0
8996
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8832
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9566
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9388
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9333
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9254
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6800
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4608
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
3
2217
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.