473,569 Members | 2,813 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to send email with from data in headers

29 New Member
The following email code is sending the values but is not sending all the values from the form.
Expand|Select|Wrap|Line Numbers
  1. $subject = $_POST["subject"];
  2. $message = $_POST["message"];
  3. $name = $_POST["name"];
  4. $from = $_POST["from"];
  5. mail('xxxx@hotmail.co.uk', 'My Subject', $message, $from);
I tried to just insert the values ($name $subject) on that line but on the email it will only post two values.
May 20 '10 #1
4 1779
Atli
5,058 Recognized Expert Expert
Look at how the function is used in the manual entry. Study that page; everything is explained there. There are even a number of examples that show exactly how to use the function for various purposes.

If that doesn't get you any closer, you may need to study how email actually works; what exactly makes up an email. That may help you understand the terms used in the manual, and how to properly use the input parameters.

I could explain all this here, but it seems rather redundant. All this information is widely available online, only a Google search away.
May 21 '10 #2
lisa007
29 New Member
I looked at it and it seems that my thick head can't get way around it. With email you need the form, to, subject, and body. I don't understand the extra parameters for the header.
May 21 '10 #3
Niheel
2,456 Recognized Expert Moderator Top Contributor
The call to the mail function in your code is wrong:

Use:
Expand|Select|Wrap|Line Numbers
  1. $to = "xxxx@hotmail.co.uk";
  2. $subject = $_POST["subject"];
  3. $message = $_POST["message"];
  4. $name = $_POST["name"];
  5. $from = $_POST["from"];
  6. mail($to,$subject,$message);
  7.  
If you want to send FROM you'll have to manipulate the headers and you can use code like this:
Expand|Select|Wrap|Line Numbers
  1. <?php
  2. $to = "xxxx@hotmail.co.uk";
  3. $subject = $_POST["subject"];
  4. $message = $_POST["message"];
  5. $name = $_POST["name"];
  6. $from = $_POST["from"];
  7. $headers = "From: $name <$from>" . "\r\n";
  8.  
  9. mail($to,$subject,$message,$headers);
  10. ?>
  11.  
As Atli suggested use http://php.net/manual/en/function.mail.php as a guide to help you create the mail output you want.
May 21 '10 #4
lisa007
29 New Member
Thank you very much. It works beautifully now I will try my best to understand better the email concept form the php manual.
May 21 '10 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

1
1307
by: _andrea.l | last post by:
Hallo! I have a list of value in an array: array_list=pippo array_list=pluto array_list=.... How to send this list or these values to a php page? for example by pushing a button (with label "send values")? Thank you in advance for the time you'll spend for answer me,
5
2134
by: Miguel Dias Moura | last post by:
Hello, i have an ASP.net / VB page with a Script (submitValues) and a Form. 1. The form has 20 input texts and a "Submit" button. 2. The script declares 20 variables. The value of each variable is taken from each of the 20 input texts. 3. When the button "Submit" is click the variable values are sent to an email address using AspNetEmail.
3
1554
by: mortb | last post by:
HI all, I'm writing a control that resides on a page which instantiates an object from the database. My goal is to make the control use the same object for the control as on the page. Something like this: Page code behind (C#): private void Page_Load(object sender, System.EventArgs e)
2
1737
by: Li Pang | last post by:
Hi, I have following codes in VB6 for sending the email on a server installed SMTP. It works fine. Now I want to update it with VB.NET 2.0 by using ..NET.Mail object. VB6 code: Dim myMail Set myMail=CreateObject("CDO.Message") myMail.Subject = "Sending email with CDO" myMail.From = "Testing" myMail.To = "someone@yahoo.com"
2
2636
by: oyster | last post by:
I find that the existing email moudle is some hard for me to understand, especially the part of how to set the CC, BCC and attach the files. Is there any more easy one like this p-code? import easyemail smtpserver=easyemail.server('something') smtpserver.login('usr@gmail.com', pwd) newletter=smtpsever.letter(smtpserver) newletter.sendto=...
1
3026
by: brendwal | last post by:
Hi, I am stumped at how to do this: I have a simple webform that I want the user to enter one value (an address). I then want the form to send those values to a PHP script that processes the address and returns 2 numeric values back to the original webform populating two textboxes in a second form on the orginal page. I have the PHP script...
2
2474
by: kennykenn | last post by:
Hi, Ive producd code to send an email after capturing info off a form,it works fine locally but when i put it live it doesnt work! the code is stopin at 'msg.send' any ideas, here the code! <%
5
2179
stepterr
by: stepterr | last post by:
Hi Everyone, I'm new to PHP and have been working on an existing from that had been in Coldfusion but needed to be converted to PHP. I have most of it working except I ran into a problem when trying to email the form, the values are showing up blank. I believe it has to do with the flow and how the last step before the email process doesn't...
2
2292
by: sindhudixit | last post by:
Hey, I am having a user fill out a form then the fields are going to uploaded to my database. So, at this point, when the user hits the submit button I want three things to happen: 1. The form uploads to a database (the following code does this) 2. An e-mail is sent to my sales team as well as the customer, which contains the form...
1
2209
by: vijayarl | last post by:
Hi All, I need to send a email based on the flag value, am using Email::Send module(CPAN). Requirement : 1.Based on the $email_flag, call the send_email function so, script goes like this: ## In main function ## if($email_flag == 1){ &send_email; ## calling the send_email sub-function
0
7703
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...
0
7926
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. ...
0
8138
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...
0
7983
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...
1
5514
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...
0
5223
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3657
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...
0
3647
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2117
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.