[SOLVED] Send Email via PHP + built-in method

moontear 19 Feb, 2008
Hello there,

I've seen several posts of people who use customized PHP code to send an e-mail, but I seem not to be able to find it anymore.

I use the built in "e-mail results" function to send me a status message with the field-names etc. I don't want users who register to receive that message and hence want to have a custom PHP mail sent to them. This will have a nicer layout and a thank you message etc.

All I need to know is how does a very simple e-mail in PHP+Joomla+Chronoforms look like and how do I call the chronoform field names (e.g. last_name, first_name).
The best would be if somebody would be able to produce the code for "Hello {first_name} {last_name}, thank you for registering".

Thx in advance,
dennis<br><br>Post edited by: moontear, at: 2008/02/19 18:37
GreyHead 19 Feb, 2008
Hi Dennis,

This request seems to be increasing so maybe Max will add it in to a future release. At the moment you have to do a workaround in the 'OnSubmit after email' box. Here's one that I did for a client this week:
<?php
$recipient = $_POST['email'];
$subject = "Medway Voice - thanks";
$html_message = "<p>Dear ".$_POST['name'].",</p>
<p>Thank you for submitting the membership form.<br />As soon as we process it you will receive your user name and password.</p>
<p>The XXX Team</p>";
mosMail($from, $fromname, $recipient, $subject, $html_message, true );
echo $html_message;
?>
This version sends an email and - in the last 'echo' line also shows it on the ThankYou page.

If you want to add field values then these can be put into the $html_message using the ".$_POST['field_name']." format.

Bob<br><br>Post edited by: GreyHead, at: 2008/02/19 12:08
moontear 19 Feb, 2008
Thank you Bob, helpful as always!
Paiyili 19 Apr, 2008

If you want to add field values then these can be put into the $html_message using the ".$_POST['field_name']." format.

Bob<br><br>Post edited by: GreyHead, at: 2008/02/19 12:08



Hi. Could you show me an example of this being done? Thanks.
moontear 19 Apr, 2008
sure will do, following the previous example:

<?php

$recipient = $_POST['email'];

$subject = "Our Newsletter - thanks";

$html_message = "<p>Dear ".$_POST['name'].",</p>

<p>Thank you for submitting the membership form.<br />As soon as we process it you will receive 
your user name and password.</p>

<p>Your username is:".$_POST['username_field']."</p>
<p>Your password is:".$_POST['password_field']."</p>

<p>The XXX Team</p>";

mosMail($from, $fromname, $recipient, $subject, $html_message, true );

echo $html_message;

?>


The line "
<p>Your password is:".$_POST['username_field']."</p>" does output the value of the field with the name "username_field". Just play around with it and your own field names / table column names.

moon

Post edited by: moontear, at: 2008/04/19 00:50<br><br>Post edited by: GreyHead, at: 2008/04/19 01:52
This topic is locked and no more replies can be posted.

VPS & Email Hosting 20% discount
hostinger