Greetings,
When I put this code to my sobi 2 template it works and sends mails to addresses inserted in listing.
<?php
$task = mosGetParam( $_REQUEST, 'task', '' );
$mySobi_id = $mySobi->id ;
switch ($task) {
case 'email' :
emaillisting($mySobi_id);
}
function emaillisting($mySobi_id) {
global $mosConfig_live_site, $mosConfig_mailfrom, $mosConfig_fromname;
$directory_email = mosGetParam( $_POST, 'directory_email', '' );
$directory_name = mosGetParam( $_POST, 'directory_name', '' );
$v_firstname = mosGetParam( $_POST, 'name', '' );
$v_email = mosGetParam( $_POST, 'email', '' );
$v_telephone = mosGetParam( $_POST, 'telephone', '' );
$v_comments = mosGetParam( $_POST, 'comments', '' );
$number = intval( mosGetParam( $_POST, 'number', 0 ) );
$othernumber = intval( mosGetParam( $_POST, 'othernumber', 0 ) );
$sum = intval( mosGetParam( $_POST, 'sum', 0 ) );
$query_text = sprintf( _DIRECTORY_CONTACT_LETTER, $v_firstname, $v_email, $v_telephone, $v_comments, $mosConfig_fromname );
if($number + $othernumber == $sum){
// - directory member
$success = mosMail( $email, $mosConfig_fromname , $directory_email, \"SeeLesotho.com Website Enquiry\", $query_text, 0, null,null,null,$v_email,$v_firstname );
// - directory owner
$success = mosMail( $email, $mosConfig_fromname , $mosConfig_mailfrom, \"Copy of SeeLesotho.com Website Enquiry for \" . $directory_name, $query_text, 0, null,null,null,$v_email,$v_firstname );
}else{
mosRedirect(\"index.php?option=com_sobi2&sobi2Task=sobi2Details&sobi2Id=$mySobi_id\", \"Message sending failed. Please insert the sum of numbers..\"«»);
}
mosRedirect(\"index.php?option=com_sobi2&sobi2Task=sobi2Details&sobi2Id=$mySobi_id\", \"Message sent successfully..\"«»);
}
?>
<?php
$number = rand(1,10);
$othernumber = rand(1,9)*10;
?>
<form action=\"<?php echo sefRelToAbs( 'index.php?option=com_sobi2&sobi2Task=sobi2Details&sobi2Id='. $mySobi->id ); ?>\"
method=\"post\" name=\"emailForm\" target=\"_top\" id=\"emailForm\">
<label>Name</label><br />
<input name=\"name\" type=\"text\" size=\"30\" /><br />
<label>Email</label><br />
<input name=\"email\" type=\"text\" size=\"30\" /><br />
<label>Telephone Number</label><br />
<input name=\"telephone\" type=\"text\" size=\"30\" /><br />
<label>Message</label><br />
<textarea name=\"comments\" cols=\"50\" rows=\"10\"></textarea>
<br />
<label>To prove you are not a spambot, please complete the sum below:<br />
<?php echo $number; ?> + <?php echo $othernumber;?> = </label>
<input type=\"text\" name=\"sum\" size=3 maxlength=3><br />
<input type=\"submit\" name=\"Submit\" value=\"Submit\" />
<input type=\"hidden\" name=\"task\" value=\"email\" />
<input type=\"hidden\" name=\"directory_email\" value=\"<?php echo $mySobi->customFieldsData['field_email']; ?>\" />
<input type=\"hidden\" name=\"directory_name\" value=\"<?php echo $mySobi->customFieldsData['field_contact_person']; ?>\" />
<input type=\"hidden\" name=\"number\" value=\"<?php echo $number; ?>\" />
<input type=\"hidden\" name=\"othernumber\" value=\"<?php echo $othernumber; ?>\" />
</form>
Now, I can use rsforms through mambot, but I need to program it to send mails to different addresses, the ones that customers wrote when they signed, not all mails to go to the administrator. Does anybody could point me how to connect with sobi 2 and program forme to do this using parts of the code above.
Thanks for the help.
Sasa