Jump to content
xisto Community
Sign in to follow this  
maria_ian21

Php Mail Tutorial SENDING MAILS WITH PHP

Recommended Posts

Notice from cmatcmextra:
Added code tags in BUT not accepting as we already have a mail tut. Pming user regrading code tags, credits have not been reduced....


First to send a mail with php we need to design an html form
eg

<form action="mailsend.php" method="post" enctype="application/x-www-form-urlencoded" name="form1">    <table width="75%" border="0">      <tr>         <td><strong><font size="4">Subject</font></strong></td>        <td><input name="subject" type="text" id="subject" size="60"></td>      </tr>      <tr>         <td><strong><font size="4">From</font></strong></td>        <td><input name="from" type="text" id="from" size="60"></td>      </tr>      <tr>         <td><font size="4"><strong>From Email</strong></font></td>        <td><input name="textfield" type="text" size="60"></td>      </tr>      <tr>         <td><strong><font size="4">Body</font></strong></td>        <td> </td>      </tr>      <tr>         <td> </td>        <td><textarea name="msg" cols="80" rows="20" id="textarea"></textarea></td>      </tr>      <tr>        <td><input type="submit" name="Submit" value="Submit"></td>        <td><input name="hiddenField" type="hidden" value="<?usr=$_POST[usr]?>"></td>      </tr>    </table>  </form>

secondly we will create the php code to collect the information and send it
the mail function is php is mail()
and inside we can put in variables containing the information we want to send
for instance we want to send a mail to someone@somewhere.com with alll info we collected from the form above included we will write a php code like this

//this will contain the email address of the reciepient$to=fgets("someone@somewhere.com");   //our subject the $_POST tells the script to get the information from the form   $subject=$_POST[subject];//our message   $msg=$_POST[message];// our headres this is usually written this way so as to get the international standar format.   $msgheaders="from:$_POST[from]\n";   $msgheaders.="<$_POST[email]>\n";      if( mail($to,$subject,$msg,msgheaders)){ print ("your mail was sucessfullysen to $to");}else  print "unable to send mail to $to";

there hope you will like it
Edited by cmatcmextra (see edit history)

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.