need help with sendmail from joomla

Started by Nitro, November 22, 2005, 05:41:58 PM

Previous topic - Next topic

Nitro

hello gang!
i am trying to send one peice of email to two different ones using this little script in the send mail but i can't, i am not sure how to put it together so it sends two emails

// send the mail
$this->sendMail(
    $mosConfig_mailfrom,                // email addr of submitter (1)
    $mosConfig_fromname.' - Message',   // name of submitter (1)
    ff_getSubmit('email')              // email of recipient (2)
    ff_getSubmit('subject'),            // subject of the mail (3)
    ff_getSubmit('message')             // body of the mail (3)
   
);


as you can see here i want the ff_getSubmit('email') to send it to the recipient AND to us. we are trying to create a invitation little script and a contest. and since this is with joomla i thought i should put this over here.

thank you, any ideas?
MPF Rocks!!!

chadness

How about just putting the whole function in a second time as well with the extra email address hard coded in place of the email variable?

Nitro

sounds good. below is the whole thing: (i hope this is what you were asking me to post here)

// declare globals used in this piece
global $mosConfig_mailfrom, $mosConfig_fromname;

// include facile forms standard library
$this->execPieceByName('ff_InitLib');

// send the mail
$this->sendMail(
    $mosConfig_mailfrom,                // email addr of submitter (1)
    $mosConfig_fromname.' - Message',   // name of submitter (1)
    ff_getSubmit('email')              // email of recipient (2)
    ff_getSubmit('subject'),            // subject of the mail (3)
    ff_getSubmit('message')             // body of the mail (3)
   
);

/*--------------------------------------------------------------------
Notes:

(1) In this sample we use the site admin as submitter of the email,
    but basicly you could use anything. Note that many mail servers
    however impose constraints about the submitters email address and
    in case refuse to sent the mail to prevent from spamming. (This
    will mostly be reported as 'relaying denied').

(2) Recipient can also be an array of email addresses if you want to
    send the same mail to multiple recipients. Note that all email
    adresses will however be visible to all recipients, so maybe
    it is better to call $this->sendMail for each recipient
    individually.

(3) Subject and body could of cause also be composed here in the
    piece instead of taking it completely from the submitted values.
--------------------------------------------------------------------*/




now in the form i have:
Email to:
Subject:
Message: (in here i have a pre-written note so the member doesn't have to worry about it)
and submit button at the bottom.

I tried to add something like this here: ff_getSubmit('email','[email protected]') that didn't work, what i am trying to do is to send a Bcc/Cc copy to us becuase this is a contest, and we want to keep track of how many invites someone sends so we can put it in a drawing of a $400 motivational set of tapes.

I checked my little knowledge i have in php and this kind of stuff, just using logic pretty much. i couldn't so i thought trying the SMF.

thank you for taking a look at this stuff, i REALLY appreicate that!!!
MPF Rocks!!!

chadness

I was thinking more of leaving that part like it is, and sending a second email to the admin.

Is that code everything in the script?  Usually when I've made Facile Forms I've used the MosMail function.

Hmmm, let's see, to do it the way you are, it might work if you wrote that line this way:
ff_getSubmit('email').',[email protected]'

Do you need a comma at the end of that line?  It seems like you would, but there wasn't in what you posted.

Nitro

yeah, there is no comma there, i noticed that but i guess it's working without it.
oh! so i should put a comma before the feedback word? oh i see! that makes sense. i am going to try this out right now.

i will let you know how it went.

awesome! thank you.
MPF Rocks!!!

Nitro

#5
this is interesting...
i get the same error i have been getting:

Parse error: pase error, unexpected T_STRING
in /homepages/20/..../facileforms.process.php
(993): eval()'d code on line 12


this is what i did:
ff_getSubmit('email'),',[email protected]'

got a pain. would you like me to give you access to the admin panel so you can see the whole picture? the thing is, everything is in peices, and it is everywhere but one page.

let me know, i'd be glad to let you in. besides that's a test site i have so if something gets messed up there is no worries.  :D

thank you.

EDIT: i tried this one ff_getSubmit('email'),'[email protected]', got no error but in the email i received there is nothing included. that's weird and there is no other copy sent to the other email.
MPF Rocks!!!

Nitro

HEY i realized something!!!
ff_getSubmit('email'),',[email protected]' when i do that, it sends the email to feedback but it doesn't send the email where to the other first 'email' so that means this works but it kills the 'email' is there a way to not make it kill the info in the 'email'?
MPF Rocks!!!

chadness

The error you were receiving is because you didn't have the comma telling it that it was the end of that variable.

I'm not sure how that formats the To part of the email.  Maybe you could do this instead.  Put that whole function back to how it originally was, then add an additional one underneath like this:

$this->sendMail(
    $mosConfig_mailfrom,                // email addr of submitter (1)
    $mosConfig_fromname.' - Message',   // name of submitter (1)
    '[email protected]',              // email of recipient (2)
    ff_getSubmit('subject'),            // subject of the mail (3)
    'Copy of mail sent to '.ff_getSubmit('email').chr(13).ff_getSubmit('message')             // body of the mail (3)
   
);

That way you can have the email to feedback be unique.

Nitro

this is interesting. i get no errors with this new code you posted here. however, i get no other copy to the other email.

i tred different ways, but not this one. even if i put this: // email of recipient (2) and the original code ff_getSubmit('email'), which is that, i get only one email that is being sent to 'email'. i am not looking forward to receive the body of the email just a notification that an email was sent from 'X' person. i just can't figure this out!

:D any more ideas?

thank you man!
MPF Rocks!!!

chadness

Well, here's how I do one of my forms.  This is the code in the "Submit Pieces" tab (email addresses changed):
// This php piece sends an email

// global $mosConfig_mailfrom, $mosConfig_fromname;

// init vars
$username = '';
$from = '';
$fromname = '';
$phone = '';
$recipient = '[email protected],[email protected],[email protected],[email protected]';
$location = '';
$equipment = '';
$request = '';
$subject = 'Tech issue';
$body = '';

// extract form data
foreach ($this->submitdata as $data)
    switch ($data[1]) {
        case 'username':
            $username = $data[4];
            break;
        case 'from':
            $from = $data[4];
            break;
        case 'fromname':
            $fromname = $data[4];
            break;
        case 'from':
            $from = $data[4];
            break;
        case 'phone':
            $phone= $data[4];
            break;
        case 'location':
            $location= $data[4];
            break;
        case 'equipment':
    $equipment= $data[4];
            break;
        case 'request':
    $request= $data[4];
            break;
        default:
            break;
    } // switch

$body = 'From: '.$fromname.chr(13).'Email: '.$from.chr(13).'Phone: '.chr(13).$phone.chr(13).'Username: '.$username.chr(13).chr(13).'Location: '.$location.chr(13).'Equipment description: '.$equipment.chr(13).'Issue description:'.chr(13).$request;

// uncomment this to debug the piece
// echo "$from $fromname $recipient $subject $body";
// exit;

// send the mail
mosMail($from, $fromname, $recipient, $subject, $body);

Nitro

oh i see. i will try this new code. this is more structured and clear. wow! you are good!
let me put this one to the test. i will post here in a 'update' reply what happened. thank you man!!!!
MPF Rocks!!!

Nitro

well, i got to tell you this is so hard, i tried your code and i got no errors! but no results, weird!
so i went and install a component 'Recommend' and i had to tweak it though to fit our needs and it works just good.
http://www.joomlaya.com/index.php?option=com_remository&Itemid=65&func=fileinfo&filecatid=840&parent=category

man! i REALLY appreciate your time you took in helping me with this little code. i can tell you are really good!!!

thank you so much!!!!
MPF Rocks!!!

chadness

I'm not that good, that's just re-written code form a facile forms sample. :)

Advertisement: