Jump to content

Multiple $message strings needed using the mail() function


Recommended Posts

Hi I have created a PHP front end to my Filemaker database that allows a user to enter details into a form that adds it to the database and then displays a confirmation page with the details that have been entered.

 

In the confirmation page code I have added the following code that sends an email with details from the record displayed in the confirmation page. Here is the code below:

 

-----------------------------------------------------------------------------------------------------------------------

<?php

        ini_set("SMTP","10.99.240.12");

                ini_set("smtp_port",25);

 

 

mail(

$to = 'sbainbridge@lshs.org.uk',

$subject = 'Network logon: '. $record->getField('Network logon', 0),

$message = 'E1 Username:'. $record->getField('E1 Username', 0),

$headers = 'From: ictservices@lshs.org.uk'."\r\n"

);

?>

----------------------------------------------------------------------------------------------------------------------

I would like to add more data from fields in the record in the confirmation php page but this is where I get syntax errors. I have tried adding the following line below the highlighted line in my code.

 

$message = 'Details:'. $record->getField('details', 0),

 

When this is entered I get a syntax error and no email is sent. The PHP code sends an email fine without this line added but I would like add multiple fields from my databse record to the message part of the email.

 

Any help will be well appreciated!

 

Thanks

 

Simon

 

 

Yeah because the mail function ONLY takes 4 parameters, NOT 5. Hence your syntax error.

What about

$message = 'E1 Username:'. $record->getField('E1 Username', 0).'Details:'. $record->getField('details', 0),

 

Or you could construct the message OUTSIDE of the mail function...

Hi thanks for your help, I found that the following code works:

 

$message = 'E1 Username:'. $record->getField('E1 Username', 0). 'Details:'. $record->getField('Details', 0),

 

This emails me both fields which is great.

 

Do you know I can put a line break in so that I can separate the data onto different lines in a email message?

 

i.e. E1 Username: username here

    Details:  Problem details here

 

Cheers Simon

Put a \n in that string, unless you're using an html format in which case you need a <br>

I recommend constructing your message outside the mail function, because i almost certainly guarantee this is going to grow and become unmanageable in it's current format.

Hi thanks for your help it now works fine.

 

I can see that it will soon get very unmanageable after adding some more fields in this string. So what is the syntax

for building the message string outside the function?

 

thanks

 

Simon.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.