Tuesday, August 30, 2011

Sending Mail in Drupal

 Sending Mail in Drupal;
This function is used  to send email a page in your site.
 
function mail_process($form=NULL){
    $base = "http://".$_SERVER['HTTP_HOST'].base_path();//base url of the parent page
    $basepath = $base.$uri; //$uri is optional
    $from = $form['mailid']['#value']; //Sender Mailid
    $to = $form['friendmailid']['#value']; //Receiver Mailid
    $fullname = $form['fullname']['#value']; //Sender Name
    $subject = $fullname.' Recommends'; //Subject
    $message_body = $form['message']['#value']; //Message
    $message = array('to' => $to,
                     'subject' => $subject ,
                     'body' => $message_body.'<br>'.$basepath,
                     'headers' =>  array(
                             'From' => $from,
                             'MIME-Version' => '1.0',
                             'Content-Type' => 'text/html; charset=UTF-8; format=flowed',
                             'Content-Transfer-Encoding' => '8Bit',
                             'X-Mailer' => 'Drupal'
                             ),
                             );
                             drupal_mail_send($message); //Sending Mail
                           }

No comments:

Post a Comment