CMSmailer usage

For questions and problems with the CMS core. This board is NOT for any 3rd party modules, addons, PHP scripts or anything NOT distributed with the CMS made simple package itself.
Locked
chipus

CMSmailer usage

Post by chipus »

hi calguy,

i am using CMSmailer 1.73.9. I failed to find documentation for the module. Could u tell me how to use it.

 

Code: Select all

$cmsmailer = $this->GetModuleInstance('CMSMailer');
  $cmsmailer->AddAddress('calguy1000@hotmail.com','calguy');
  $cmsmailer->SetBody('<h1>This is a test message<h1>');
  $cmsmailer->IsHTML(true);
  $cmsmailer->SetSubject('Test message');
  $cmsmailer->Send();
I understand the sample code. However, what should i do if i want to use it this way:

    - I create a contact form, which is content many fields. How could i add them into the body of the email, like: name, address, fone....
    - I want to add the content body for my email, what should i do?

Hope to hear from you soon.


Regards,

chipus.
calguy1000
Support Guru
Support Guru
Posts: 8169
Joined: Tue Oct 19, 2004 6:44 pm

Re: CMSmailer usage

Post by calguy1000 »

Well, the body of the message is just a string, so you can put whatever information you want in to that string and then just call
$cmsmailer->SetBody( $body ); // assuming $body is the string that holds it

I personally use smarty templates to build up most of my mail messages. 

Putting the results of your form into the body is no issue, you just have to get access to those variables and append them to the body string.
i.e.: 

$body = '';
$body .= 'Name: '.$_POST['name'].'';
$body .= 'Address: '.$_POST['address'].'';
$cmsmailer->SetBody( $body );

Hope this helps
Follow me on twitter
Please post system information from "Extensions >> System Information" (there is a bbcode option) on all posts asking for assistance.
--------------------
If you can't bother explaining your problem well, you shouldn't expect much in the way of assistance.
User avatar
Dr.CSS
Moderator
Moderator
Posts: 12711
Joined: Thu Mar 09, 2006 5:32 am

Re: CMSmailer usage

Post by Dr.CSS »

it is used for internally generated email ie. when you have something on your website say a form, someone fills out the form and hits submit button, all the fields/questions/textboxes and answers/input are emailed to the add. of your choosing, you have to specify the add. in the form when you create it, at the top you add a field type in the drop down select * Email Results to Set Address(es) next page has the field name i call it email then next box down, Email Address(es) to Send Form Results:  you put the email add. you want the form results sent to, when you are done with the form don't forget to clik  Create Sample Template  button.....

  mark
User avatar
Dr.CSS
Moderator
Moderator
Posts: 12711
Joined: Thu Mar 09, 2006 5:32 am

Re: CMSmailer usage

Post by Dr.CSS »

chipus

Re: CMSmailer usage

Post by chipus »

mark wrote: like this.... http://multiintech.com/ruth/index.php?page=questionaire

   mark
Yes, it is. I have the form already, but i don't know how to put the code into the content so it could work.

I mean i don't know where to put the CMSmailer code

Could u show me the code, Mark.

Thanks a lot

PS: do u use msn messenger or Ym ? i am happy to talk to u ^_^
Last edited by chipus on Mon May 29, 2006 4:07 am, edited 1 time in total.
User avatar
Dr.CSS
Moderator
Moderator
Posts: 12711
Joined: Thu Mar 09, 2006 5:32 am

Re: CMSmailer usage

Post by Dr.CSS »

ok here goes... you want to make a form and you want to be emailed the results...
install the CMSMailer module...
install the FeedbackForm module...
in the  Extensions » CMSMailer Module... set like the first img. below... and send a test to your email add. in the Test Email Address: box
use a real add. ... check your mail in a few minutes, You Got Mail... ok it works..
in FeedbackForm .. 'clik' Add New Feedback Form... fill out info for form 'clik' Add button.. you get page with name and alias of form at bottom 'clik'  "Add New Field" first field...  Field Type:  dropdown has  * Email Results to Address(es)  choose that.. next page looks like next img. below... fill in the info and 'clik' "ADD" button, now the form can be filled with your fields.. when you are done it will tell you what tag to use for the form eg.  {cms_module module='FeedbackForm' form='test'}  your form name...  ok...
this works for me i don't know about the rest of that code stuff you guys were talking about...

{php} if ( isset($_POST['hid_frm_posted']) && ($_POST['hid_frm_posted']=='frm_posted'))
{ global $gCms;
$cmsmailer = $gCms->modules['CMSMailer']['object'];
$body = ''; $body .= 'Name: '.$_POST['fname'].'
';
$body .= 'Address: '.$_POST['address'].'
';
$cmsmailer->AddAddress('chip.chipus@gmail.com','calguy');
$cmsmailer->SetBody($body);

[attachment deleted by admin]
Last edited by Anonymous on Tue May 30, 2006 5:44 am, edited 1 time in total.
chipus

Re: CMSmailer usage

Post by chipus »

ok, Thanks very much, mark

I am trying ^_^
danster

Re: CMSmailer usage

Post by danster »

Ques about using the php mail function independent of the CMSmailer module.
-----------------------------------
I have a form set up in a "content" page which submits to another "content" page in which I have placed a UDT called {testmailer}. the contents of the UDT testmailer are below. unforunat. it won't work. I've used this method in another site withouth any problems. is it possibly because I'm running "Maui" now as opposed to "Canary" in the other site? pretty frustrating. i realize the CMSmailer now exists, but I'm short on time and just want to wrap this up. thanks for any help or advice anyone can share.


if(isset($_POST['submit'])) {

$to = "you@you.com";
$subject = "Form Tutorial";
$name_field = $_POST['name'];
$email_field = $_POST['email'];
$message = $_POST['message'];

$body = "From: $name_field\n E-Mail: $email_field\n Message:\n $message";

echo "Data has been submitted to $to!";
mail($to, $subject, $body);

} else {

echo "blarg!";

}
danster

Re: CMSmailer usage

Post by danster »

danster wrote: Ques about using the php mail function independent of the CMSmailer module.
-----------------------------------
I have a form set up in a "content" page which submits to another "content" page in which I have placed a UDT called {testmailer}. the contents of the UDT testmailer are below. unforunat. it won't work. I've used this method in another site withouth any problems. is it possibly because I'm running "Maui" now as opposed to "Canary" in the other site? pretty frustrating. i realize the CMSmailer now exists, but I'm short on time and just want to wrap this up. thanks for any help or advice anyone can share.


if(isset($_POST['submit'])) {

$to = "you@you.com";
$subject = "Form Tutorial";
$name_field = $_POST['name'];
$email_field = $_POST['email'];
$message = $_POST['message'];

$body = "From: $name_field\n E-Mail: $email_field\n Message:\n $message";

echo "Data has been submitted to $to!";
mail($to, $subject, $body);

} else {

echo "blarg!";

}
well, this has nothing to do with CMSMS. i can't even get the mail func to work outside of the cms app, in separate php files. UG!!!!
Locked

Return to “CMSMS Core”