i would like to click on the name of a person to email him.
for eg, if i click on "John", i shd be able to send an email to his email id. how is that done ? pls help.

Comments

naveenpl’s picture

// menu for redirecting function.
$menus[] = array('path' => 'path/function',
'title'=>t('title'),
'callback' => 'function_name',
'access' => user_access('user request'),
);
// loop where name is displayed, which is redirected to another function
while ($propGroupRow = db_fetch_object($result)) {
$rows[] = array(
l(t('Name'), 'path/function/'.$mailid));
}

function function_name() {
// write subject , message, from and header.

// drupal function to send mail.
drupal_mail('comment_subscribe_mail',$mailid, $subject, $message, $from, $headers);
}

Hop this helps.
Cheers

Lakshmipriya-1’s picture

Thanks Naveen ..but could you pls explain where and how do i use this code. That would be very helpful as i have no idea..
looking fwd to hear frm u.
thnks.

naveenpl’s picture

I suppose you have experience in developing modules.

function YOUR_MODULE_menu() {

// menu for redirecting function.
//'callback' => 'function_name', call back function to send mail.
// path' => 'path/function', Path given to the page where the function is executed.
$menus[] = array('path' => 'path/function',
'title'=>t('title'),
'callback' => 'function_name',
'access' => user_access('user request'),
);
return menus;
}
// function where you display the user name
function FUNCTION_NAMES_LISTED() {

// loop where name is displayed, which is redirected to another function
while ($propGroupRow = db_fetch_object($result)) {
$rows[] = array(
l(t('Name'), 'path/function/'.$mailid));
}

// (t('Name'), 'path/function/'.$mailid)); here is the path to the given above (PATH GIVEN AT hook_menu)
// .$mailid is the mailid of corresponding user.
// This will display a list with name and when you click this name you will be redirected to anothe page of the path : path/function/'.$mailid
}

// function to send mail (FUNCTION NAME IS GIVEN AT CALLBACK at hook_menu)
function FUNCTION_TO_SEND_MAIL() {

// write subject , message, from and header.
// drupal function to send mail.
drupal_mail('comment_subscribe_mail',$mailid, $subject, $message, $from, $headers);

}

sample code, how to send mail (with subject messages and other details)can be seen at notify module or other similar modules that deals with mailing.

Hope this will helps
Cheers