How to send mail when a variable is not passed in msgHTML()

Send form data with SMTP - PHP Cluster
Send form data with SMTP – PHP Cluster

I have a faced this problem when i was integrating SMTP mail for first time. Then after lots of attempt i got success in sending form value with variable in msgHTML(). Therefore, I thought to share this successful attempt with all programmers. I have shown below how to send variable in msgHTML().
Let us see below::

1) Rreplace $mail->msgHTML($msg) with the body function :

as I have written this code below:

$mail->IsHTML(true);
$mail->Body='Name:  '.$_POST['name'].'<br />
Email:  '.$_POST['email'].'<br />
Sujet:  '.$_POST['subject'].'
<br /><br />

'.nl2br($_POST['msg']).'

<br /><br /> ;

$mail->Send();

You can easily send mail when a variable value is not passed into //$mail->MsgHTML(”);

This is very simple steps to pass all the form data into mail using SMTP(Simple Mail Transfer Protocol).

That’s all.