From: Joe Jackson on 19 Sep 2010 18:00 Hi Sorry for the simple question but I am trying to get my head around PHP. I have a sample PHP script that I am trying to use to send a php powered email message. The snippet of code is shown below.... mail('email(a)address.com', 'Subject', $values['message'], "From: \"{$values['name']}\" <{$values['emailaddress']}>"); This works fine, but how can I add in other fields to the email that is recieved? For example in the form there are fields called, 'emailaddress', 'telephone', 'address' and 'name' which I need to add into the form along with the message field Also with the formatting how can I change the format of the email to Name: $values['name'], Address: etc Message: TIA
From: Bostjan Skufca on 19 Sep 2010 18:29 You should format the email message content first, like this: $msgContent = "Name: ". $values['name'] ."\n"; $msgContent .= "Address: ". $values['address'] ."\n"; Then you should send a this content, like this: mail('email(a)address.com', 'Subject', $msgContent, "From...); b. On 20 September 2010 00:00, Joe Jackson <priorybar(a)googlemail.com> wrote: > Hi > > Sorry for the simple question but I am trying to get my head around PHP. I > have a sample PHP script that I am trying to use to send a php powered email > message. The snippet of code is shown below.... > > mail('email(a)address.com', 'Subject', $values['message'], "From: > \"{$values['name']}\" <{$values['emailaddress']}>"); > > This works fine, but how can I add in other fields to the email that is > recieved? > > For example in the form there are fields called, 'emailaddress', > 'telephone', 'address' and 'name' which I need to add into the form along > with the message field > > Also with the formatting how can I change the format of the email to > > Name: $values['name'], > Address: etc > Message: > > TIA >
From: TR Shaw on 19 Sep 2010 18:37 On Sep 19, 2010, at 6:00 PM, Joe Jackson wrote: > Hi > > Sorry for the simple question but I am trying to get my head around PHP. I > have a sample PHP script that I am trying to use to send a php powered email > message. The snippet of code is shown below.... > > mail('email(a)address.com', 'Subject', $values['message'], "From: > \"{$values['name']}\" <{$values['emailaddress']}>"); > > This works fine, but how can I add in other fields to the email that is > recieved? > > For example in the form there are fields called, 'emailaddress', > 'telephone', 'address' and 'name' which I need to add into the form along > with the message field > > Also with the formatting how can I change the format of the email to > > Name: $values['name'], > Address: etc > Message: > Joe The mail command lets you send mail (an RFC2821 envelop). The function is: bool mail ( string $to , string $subject , string $message [, string $additional_headers [, string$additional_parameters ]] ) $to is where you want it to go $subject is whatever you want the subject to be $message is the information you want to send Ignore the other parameters unless you are very familiar with RFCs 2821, 2822 and their associated RFCs So if you want to send info from a form you might want to roll it up in xml and send it via the message part. when you receive it you can easily decode it. If you don't want to do that put it in a format that you can easily decode on the receiving end. Basically "mail" is a way to deliver information in the $message body. How you format the information there is up to you. However, depending on your system's config you are probably constrained to placing only 7bit ascii in the $message body. You might also move away from the mail function and look at phpmailer at sf.net if you need more complex capabilities. Tom
From: Joe Jackson on 20 Sep 2010 07:35 Hi All I need is in the message body of the email is to include more data from the form. At present it only displays the 'message' field value in the body of the email. I need to add further information into the email from the form such as 'address' 'name' and 'telephone number' When I have tried to add them into the PHP script $values['message'], ['name'], ['address'], ['telephonenumber'], I am getting PHP errors, what would be the correct syntax I would need to use to get the following form field values into the email body. I greatly appreciate all your expert advice and help. On Sun, Sep 19, 2010 at 11:37 PM, TR Shaw <tshaw(a)oitc.com> wrote: > > On Sep 19, 2010, at 6:00 PM, Joe Jackson wrote: > > Hi > > Sorry for the simple question but I am trying to get my head around PHP. I > have a sample PHP script that I am trying to use to send a php powered > message. The snippet of code is shown below.... > > mail('email(a)address.com', 'Subject', $values['message'], "From: > \"{$values['name']}\" <{$values['emailaddress']}>"); > > This works fine, but how can I add in other fields to the email that is > recieved? > > For example in the form there are fields called, 'emailaddress', > 'telephone', 'address' and 'name' which I need to add into the form along > with the message field > > Also with the formatting how can I change the format of the email to > > Name: $values['name'], > Address: etc > Message: > > > Joe > > The mail command lets you send mail (an RFC2821 envelop). The function is: > > bool *mail* ( string $to , string $subject , string $message [, string > $additional_headers [, string$additional_parameters ]] ) > > $to is where you want it to go > $subject is whatever you want the subject to be > $message is the information you want to send > Ignore the other parameters unless you are very familiar with RFCs 2821, > 2822 and their associated RFCs > > So if you want to send info from a form you might want to roll it up in xml > and send it via the message part. when you receive it you can easily decode > it. If you don't want to do that put it in a format that you can easily > decode on the receiving end. > > Basically "mail" is a way to deliver information in the $message body. How > you format the information there is up to you. However, depending on your > system's config you are probably constrained to placing only 7bit ascii in > the $message body. > > You might also move away from the mail function and look at phpmailer at > sf.net if you need more complex capabilities. > > Tom > > > >
From: TR Shaw on 20 Sep 2010 07:51 Example: $to = 'nobody(a)example.com'; $subject = 'the subject'; $message = "formdata=" . serialize($form_values); $headers = 'From: webmaster(a)example.com' . "\r\n" . 'Reply-To: webmaster(a)example.com' . "\r\n" . 'X-Mailer: PHP/' . phpversion(); mail($to, $subject, $message, $headers); You can put whatever you want in $message and format it however you want. In this case we serialize an array of values/ When received, we unserialize after "formdata=". If you want it human readable format it accordingly. Tom On Sep 20, 2010, at 7:35 AM, Joe Jackson wrote: > Hi > > All I need is in the message body of the email is to include more data from > the form. At present it only displays the 'message' field value in the body > of the email. I need to add further information into the email from the > form such as 'address' 'name' and 'telephone number' > When I have tried to add them into the PHP script > > $values['message'], ['name'], ['address'], ['telephonenumber'], > > I am getting PHP errors, what would be the correct syntax I would need to > use to get the following form field values into the email body. > > I greatly appreciate all your expert advice and help. > > > On Sun, Sep 19, 2010 at 11:37 PM, TR Shaw <tshaw(a)oitc.com> wrote: > >> >> On Sep 19, 2010, at 6:00 PM, Joe Jackson wrote: >> >> Hi >> >> Sorry for the simple question but I am trying to get my head around PHP. I >> have a sample PHP script that I am trying to use to send a php powered >> message. The snippet of code is shown below.... >> >> mail('email(a)address.com', 'Subject', $values['message'], "From: >> \"{$values['name']}\" <{$values['emailaddress']}>"); >> >> This works fine, but how can I add in other fields to the email that is >> recieved? >> >> For example in the form there are fields called, 'emailaddress', >> 'telephone', 'address' and 'name' which I need to add into the form along >> with the message field >> >> Also with the formatting how can I change the format of the email to >> >> Name: $values['name'], >> Address: etc >> Message: >> >> >> Joe >> >> The mail command lets you send mail (an RFC2821 envelop). The function is: >> >> bool *mail* ( string $to , string $subject , string $message [, string >> $additional_headers [, string$additional_parameters ]] ) >> >> $to is where you want it to go >> $subject is whatever you want the subject to be >> $message is the information you want to send >> Ignore the other parameters unless you are very familiar with RFCs 2821, >> 2822 and their associated RFCs >> >> So if you want to send info from a form you might want to roll it up in xml >> and send it via the message part. when you receive it you can easily decode >> it. If you don't want to do that put it in a format that you can easily >> decode on the receiving end. >> >> Basically "mail" is a way to deliver information in the $message body. How >> you format the information there is up to you. However, depending on your >> system's config you are probably constrained to placing only 7bit ascii in >> the $message body. >> >> You might also move away from the mail function and look at phpmailer at >> sf.net if you need more complex capabilities. >> >> Tom >> >> >> >>
|
Next
|
Last
Pages: 1 2 3 Prev: Removing empty paragraphs from HTML file using simple_html_dom.php Next: Auto-generating HTML |