Page 1 of 1

Broken link - Button

Posted: 30 Mar 2010, 16:25
by cohenu
I am trying to add a button that will send me an email when someone click on it.
I saw that I need to send this variable- $valueDoc->title
someone can help me to use mail function to send an email with this variable?

Thanks a lot :wink:

Re: Broken link - Button

Posted: 01 Apr 2010, 20:25
by Jan
Hi, try to see the Joomla! framework guides, there should be described mail function.

Jan

Re: Broken link - Button

Posted: 02 Apr 2010, 18:18
by cohenu
10x Jan I will :|

Re: Broken link - Button

Posted: 02 Apr 2010, 20:15
by cohenu
Where I am wrong with this?
every time I am refresh the page it send an email how can I make it send just on click?

Code: Select all

$from = 'broken@domain.com';
$fromname = 'BrokenLink@domain.com';
$subject = 'BrokenLink';
$body =  $valueDoc->title;
$recipient[] = 'myemail@gmail.com';
JUtility::sendMail($from, $fromname, $recipient, $subject, $body);
echo '<a href="#" onclick='sendMail()'>Broken Link</a>';
I put it in the end of default.php at file view

Re: Broken link - Button

Posted: 03 Apr 2010, 13:56
by Jan
Hi, sorry I don't understand. You have some javascript which call some javascript function, but the code is PHP :idea:

Jan

Re: Broken link - Button

Posted: 05 Apr 2010, 11:34
by cohenu
Yeah as you can see I not learning anything, all I do is guessing :lol:

so I have a php code that can send email and it work.
I can make a button that call this page or I can put that code in the file view.
if I put it in different page I don't know how to send this variable - $valueDoc->title to mail.php
if I put the code in the same page every refresh it send and email so I need to put in inside a function and trigger it with onclick but I don't manage to do it.

I try a lot of things and search the internet but I don't find a way to make it stop sending email every refresh, if I am putting the mail function inside function I don't manage to call it with onclick what I am doing wrong?

Re: Broken link - Button

Posted: 07 Apr 2010, 11:21
by Jan
The mail function can be called only by PHP, so you need to send some form data to work with php again and send the email.