473,386 Members | 2,042 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,386 software developers and data experts.

What's Missing From This Form Mail Code?

I've got this form mail program that is called as an action from an HTML
form. It runs with no errors, but the email is never sent - at least,
it's never received. Here's the code:

<?
$email = $_REQUEST['email'] ;
$message = $_REQUEST['message'] ;

$address = $_REQUEST['address'] ;
$city_state = $_REQUEST['city_state'] ;
$zip = $_REQUEST['zip'] ;
$phone = $_REQUEST['phone'] ;
$email = $_REQUEST['email'] ;
$comments = $_REQUEST['comments'] ;
$name = $_REQUEST['name'] ;

$text = $name . ' - ' . $address . ' - ' .
$city_state . ' - ' . $zip . ' - ' . $phone . ' - ' . $email . ' -
' . ' - ' . $comments;

mail( "an@email.com", "subject line",
"$text", "From: $email" );
header( "Location: http://www.mydomain.com/Contact/thanks.html" );
?>

What am I missing? Thanks in advance to all for any info.
Dec 8 '06 #1
6 1241
Message-ID: <vi************************@news.west.earthlink.ne tfrom
Vik Rubenfeld contained the following:
mail( "an@email.com", "subject line",
"$text", "From: $email" );
header( "Location: http://www.mydomain.com/Contact/thanks.html" );
?>

What am I missing? Thanks in advance to all for any info.
The first thing you are missing is some sanitising of the email address.
You need to strip out any newline characters. That isn't the problem,
just good practice.

Assuming you are replacing an@email.com with a valid email address you
could try

if(mail( "an@email.com", "subject line",
"$text", "From: $email" )){
header( "Location: http://www.mydomain.com/Contact/thanks.html" );
}
else{
echo "mail could not be sent";
}

This will check if mail is actually being received for posting.

--
Geoff Berrow (put thecat out to email)
It's only Usenet, no one dies.
My opinions, not the committee's, mine.
Simple RFDs http://www.ckdog.co.uk/rfdmaker/
Dec 8 '06 #2
Thanks, Geoff. I added the code in, and it ran with no errors. But when
I entered my own email address on the form, I received no email from the
site. What could explain this?
-Vik

Geoff Berrow <bl******@ckdog.co.ukwrote:
Assuming you are replacing an@email.com with a valid email address you
could try

if(mail( "an@email.com", "subject line",
"$text", "From: $email" )){
header( "Location: http://www.mydomain.com/Contact/thanks.html" );
}
else{
echo "mail could not be sent";
}

This will check if mail is actually being received for posting.
Dec 8 '06 #3
Vik Rubenfeld wrote:
Thanks, Geoff. I added the code in, and it ran with no errors. But when
I entered my own email address on the form, I received no email from the
site. What could explain this?
-Vik

Geoff Berrow <bl******@ckdog.co.ukwrote:

>Assuming you are replacing an@email.com with a valid email address you
could try

if(mail( "an@email.com", "subject line",
"$text", "From: $email" )){
header( "Location: http://www.mydomain.com/Contact/thanks.html" );
}
else{
echo "mail could not be sent";
}

This will check if mail is actually being received for posting.
Just a thought, ... my ISP was blocking the IP address of the shared
server my site is on and bouncing all emails sent from it. I found the
bounce messages in the default mailbox at my domain.

--
*****************************
Chuck Anderson • Boulder, CO
http://www.CycleTourist.com
*****************************
Dec 8 '06 #4
>I've got this form mail program that is called as an action from an HTML
>form. It runs with no errors, but the email is never sent - at least,
it's never received. Here's the code:
You are permitting someone (spammers) to mail to anyone they want
(thousands of recipients) by injecting headers by putting newlines
in $_REQUEST['email']. Within about 5 minutes of putting that form
up, most ISPs will block mail from the server you have it on. Within
an hour, you probably will have blocked it also.
Dec 9 '06 #5
Message-ID: <vi************************@news.west.earthlink.ne tfrom
Vik Rubenfeld contained the following:
>Thanks, Geoff. I added the code in, and it ran with no errors. But when
I entered my own email address on the form, I received no email from the
site. What could explain this?
mail() returns true if the mail is accepted for delivery, it does not
guarantee delivery. Do we know that the server is configured properly?

Where are you running the script?

--
Geoff Berrow (put thecat out to email)
It's only Usenet, no one dies.
My opinions, not the committee's, mine.
Simple RFDs http://www.ckdog.co.uk/rfdmaker/
Dec 9 '06 #6
Message-ID: <12*************@corp.supernews.comfrom Gordon Burditt
contained the following:
>
You are permitting someone (spammers) to mail to anyone they want
(thousands of recipients) by injecting headers by putting newlines
in $_REQUEST['email']. Within about 5 minutes of putting that form
up, most ISPs will block mail from the server you have it on. Within
an hour, you probably will have blocked it also.
I think that may be a slight exaggeration, but I have already pointed
this out to the OP.

--
Geoff Berrow (put thecat out to email)
It's only Usenet, no one dies.
My opinions, not the committee's, mine.
Simple RFDs http://www.ckdog.co.uk/rfdmaker/
Dec 9 '06 #7

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

Similar topics

28
by: Mike Wilcox | last post by:
I have the following code to select an item from a drop down menu and call the same script over again. I am expecting that after the first time the script is run the first echo would produce the...
35
by: Don Vaillancourt | last post by:
Over the years I have always used the decimal(18,0) as the datatype for primary keys. Aside from the number of significant numbers involved, would BigInt type be better for performance or is...
6
by: Just Me | last post by:
My Task List contains the following: At least one reference is missing the 'Name' attribute. Any suggestion on how toe find which project is missing it? Solution contains 25 projects. ...
7
by: KatMagic | last post by:
I took the following code sample from an article about sending email via asp.net. The error I get says: System.ComponentModel.Win32Exception: No application is associated with the specified file...
1
by: mr k | last post by:
Hi, I wanted to use mail merge with forms but Text form fields are not retained during mail merge in Word, I got the code from Microsoft but it doesn't remember the text form field options such as...
2
by: carringtonf | last post by:
Okay, I have a form up that worked fine until recently. My hosting (1&1) is denying that they did anything, and that they can't assist me. So I turn to you. Form location -...
6
by: Harshpandya | last post by:
Hi all, I am working on the form in which you fill out the whole PHP form and e mail that details to someone. It is working fine. But now i want to send the same form to be sent to different...
1
by: IcarusZulu | last post by:
Hi all I have a mail form on my website. 99% of the time it works fine however sometimes it dose not. Whats happening is when a customer hits submit the content data is lost. I think it has...
8
by: =?Utf-8?B?Q2hyaXMgSGFsY3Jvdw==?= | last post by:
Hi there I've successfully added some .NET validation controls to a page (using <asp:RequiredFieldValidator ...), however when I try to set the 'display' property to 'dynamic', my page then...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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...

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.