How do I send verification mail from my drupal custom module? I have written a custom module, which can send simple mail. how do I send mail so that user should get the verification link or something similar.

&lt;?php    
/**
* implements hooks_menu
*/

function planet_extension_menu(){
$items['planetext']=array(
'title' =&gt; t('DEMO Planet Extension'),
'description' =&gt; 'Feeds aggregation ',
'page callback' =&gt; 'drupal_get_form',
'page arguments' =&gt; array('planet_extension'),
'access callback' =&gt; TRUE,
);
return $items;
}

// callback function
function planet_extension($form,&amp;$form_submit){
$form['url']=array(
'#title' =&gt; 'URL',
'#type' =&gt; 'textfield',
'#required' =&gt; TRUE,
'#size' =&gt; 35,
'#description' =&gt; t('Enter the URL'),
'#attributes' =&gt;array('placeholder' =&gt; t('www.example.com'))
);
$form['title']=array(
'#title' =&gt; 'Title',
'#type' =&gt; 'textfield',
'#required' =&gt; TRUE,
'#size' =&gt; 35,
'#description' =&gt; t('Enter the Title'),
'#attributes' =&gt;array('placeholder' =&gt; t('Title'))
);
$form['email']=array(
'#title' =&gt; 'email',
'#type' =&gt; 'textfield',
'#required' =&gt; TRUE,
'#size' =&gt; 35,
'#description' =&gt; t('Enter you valid email'),
'#attributes' =&gt;array('placeholder' =&gt; t('example@example.com'))
);
$form['submit']=array(
'#type' =&gt;'submit',
'#value' =&gt; 'Submit',
);
return $form;
}

// below is the form submission function
function planet_extension_submit($form,$form_state){
//store the values entered in form into variables
$values = array(
'url' =&gt; $form_state['values']['url'],
'title' =&gt; $form_state['values']['title'],
'email' =&gt; $form_state['values']['email'],
);
//insert the variables into the table
$insert = db_insert('planet_extension')
                -&gt; fields(array(
                        'url' =&gt; $values['url'],
                        'title' =&gt; $values['title'],
                        'email' =&gt; $values['email'],
                ))
                -&gt;execute();

drupal_mail('planet_extension', 'planet_extension_mail', $form_state['values']['email'], 'en', array('values' =&gt; $values));

        drupal_set_message(t('Form submitted. Check your email for verification')); //custom message after form submission is successful
}


//implements hook_mail
function planet_extension_mail ($key, &amp;$message, $params) {
  switch ($key) {
    case 'planet_extension_mail':
      $message['subject'] = t('Hello');
      $message['body'][] = t('Hello user');
      $message['body'][] = t('The main part of the message.');
      break;
  }
}
I am not sure about what kind of verification emails you are sending, though I believe if you peep inside drupal core user module you can get hold of function which does the same,as for user registration process we have email verification option also.

A very simple straight custom way might go in the following way


How you will be generating the verification code?

while sending the email create a link something like www.mydomain.com/email-verification/%random_string%

Create a custom table with column as email,random_string,verified
once you have generated it, make a db query to insert the link you created a point back against the email user entered and set verified to 0 in the custom table.
send the email
In your custom module implement hook_menu() with menu entry fir "email-verification" .
In the page callback using wild card check if the random_string exists in you custom table, if so set verified to 1


Not exact but close to what you may need.

Update:

global $base_url;
$random_string = substr(str_shuffle(md5(time())),0,10);
// Link 
$email_link = $base_url . "/email-verification/" . $random_string;