Re: PHP Email Question

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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

Bostjan already gave you the answer.

But, here is another example of how I do it.  It is VERY raw...

mail('email@xxxxxxxxxxx', 'Subject', print_r($values, 1), "From...");

It isn't pretty, but it works.  I have a cron job that emails every 5 minutes
with results formated by the print_r() function.  It will take everything you
have in $values and print it out formated in a nested table like structure.



> 
>  $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@xxxxxxxx> 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
>> email
>> message.  The snippet of code is shown below....
>>
>>    mail('email@xxxxxxxxxxx', '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
>>
>>
>>
>>
> 


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux