Hi,
I had a working form in version 3.0 Stable. But the I wanted to be able to attach file to my email form so I upgraded to version 3.1 RC5.5. I have seen in the faq that the method to add emailaddresses via php changed but i can't get it to work.
In 3.0 stable I used the folowing code. The first if sends a copy of the email if requested with a checkbox (kopie) and gets the emailaddress from a textfield(eigenmail).
The next ones are checkboxes to select the recipients
I tried to change to code to get it working in version 3.1, I tried the following but it didn't work (I left out the last checkboxes because method will be the same). Could somebody find out what the problem is?
I had a working form in version 3.0 Stable. But the I wanted to be able to attach file to my email form so I upgraded to version 3.1 RC5.5. I have seen in the faq that the method to add emailaddresses via php changed but i can't get it to work.
In 3.0 stable I used the folowing code. The first if sends a copy of the email if requested with a checkbox (kopie) and gets the emailaddress from a textfield(eigenmail).
The next ones are checkboxes to select the recipients
<?php
if(JRequest::getVar('kopie')) {
$emails[0]->bcc .= ','.JRequest::getVar('eigenmail');
}
if(JRequest::getVar('cantincrode')) {
$emails[0]->bcc .= ',mail1@exemple.com';
if(JRequest::getVar('dijle')) {
$emails[0]->bcc .= ',mail2@exemple.com';
}
if(JRequest::getVar('molenbos')) {
$emails[0]->bcc .= ',mail3@exemple.com';
}
if(JRequest::getVar('rupel')) {
$emails[0]->bcc .= ',mail4@exemple.com';
}
if(JRequest::getVar('waverheide')) {
$emails[0]->bcc .= ',mail5@exemple.com';
}
if(JRequest::getVar('gouwbureau')) {
$emails[0]->bcc .= ',mail6@exemple.com';
}
if(JRequest::getVar('gouwraad')) {
$emails[0]->bcc .= ',mail7@exemple.com';
}
if(JRequest::getVar('gouwoverleg')) {
$emails[0]->bcc .= ',mail8@exemple.com';
}
?>I tried to change to code to get it working in version 3.1, I tried the following but it didn't work (I left out the last checkboxes because method will be the same). Could somebody find out what the problem is?
<?php
$MyForm =& CFChronoForm::getInstance('mailing');
$MyFormEmails =& CFEMails::getInstance($MyForm->formrow->id);
if(JRequest::getVar('kopie')) {
$MyFormEmails->setEmailData(1, 'bcc', .JRequest::getVar('eigenmail'));
}
if(JRequest::getVar('cantincrode')) {
$MyFormEmails->setEmailData(1, 'bcc', 'mail1@exemple.com');
}
?>
Hi braziboy,
Silly question but how do you know it isn't working?
Where have you put this code? and
What do you see if you submit the form with DeBug on?
Bob
Silly question but how do you know it isn't working?
Where have you put this code? and
What do you see if you submit the form with DeBug on?
Bob
Thanks for the fast reply
I know it isn't working because I tried it out. In the code from my previous post I replaced the original emailaddresses with [email]mailx@exemple.com[/email].
I have put the code in the 'On submit - before sending'.
Below you see the screen I get after I submit the form. I blacked out the from and to emailaddresses. This are the ones that are configured in the 'Setup emails' and the to address receives the email message.
I know it isn't working because I tried it out. In the code from my previous post I replaced the original emailaddresses with [email]mailx@exemple.com[/email].
I have put the code in the 'On submit - before sending'.
Below you see the screen I get after I submit the form. I blacked out the from and to emailaddresses. This are the ones that are configured in the 'Setup emails' and the to address receives the email message.
Hi Braziboy,
One more question - does your site use the PHP Mail Function as the mail server? We do know that his doesn't support either CC or BCC
Bob
One more question - does your site use the PHP Mail Function as the mail server? We do know that his doesn't support either CC or BCC
Bob
The website uses Sendmail as mail server. And the fact is I already tried it with 'to' instead of bcc, but still no results. In version 3.0 it worked with bcc. The only problem is that I don't really know how to program that the emailaddresses are added to the bcc field in the database.
Hi braziboy,
I had a dig around in the code and it looks as though the setEmailData() function you used should work. If not perhaps this will do the trick
Bob
I had a dig around in the code and it looks as though the setEmailData() function you used should work. If not perhaps this will do the trick
<?php
$email =& $MyFormEmails->emails[0];
$email->cc .= ",user@example.com";
?>Bob
Thanks for the reply.
I tried it and I found out that both functions work if I take them out of the if statement. So there's a problem with the if statement. At this moment I don't have time to look at it, but I'll try to find the problem myself. If I can't find the problem I'll come back and post what I tried.
I tried it and I found out that both functions work if I take them out of the if statement. So there's a problem with the if statement. At this moment I don't have time to look at it, but I'll try to find the problem myself. If I can't find the problem I'll come back and post what I tried.
This topic is locked and no more replies can be posted.
