Advertisement
Guest User

Untitled

a guest
Dec 20th, 2015
283
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.58 KB | None | 0 0
  1. <?php
  2. $name = $_POST['name'];
  3. $email = $_POST['email'];
  4. $message = $_POST['message'];
  5. $from = 'From: yoursite.com';
  6. $to = 'contact@yoursite.com';
  7. $subject = 'Customer Inquiry';
  8. $body = "From: $namen E-Mail: $emailn Message:n $message";
  9.  
  10. if ($_POST['submit']) {
  11. if (mail ($to, $subject, $body, $from)) {
  12. echo '<p>Your message has been sent!</p>';
  13. } else {
  14. echo '<p>Something went wrong, go back and try again!</p>';
  15. }
  16. }
  17. ?>
  18.  
  19. error_reporting(-1);
  20. ini_set('display_errors', 'On');
  21. set_error_handler("var_dump");
  22.  
  23. $headers = array("From: from@example.com",
  24. "Reply-To: replyto@example.com",
  25. "X-Mailer: PHP/" . PHP_VERSION
  26. );
  27. $headers = implode("rn", $headers);
  28. mail($to, $subject, $message, $headers);
  29.  
  30. $headers = array("From from@example.com", // missing colon
  31. "Reply To: replyto@example.com", // missing hyphen
  32. "X-Mailer: "PHP"/" . PHP_VERSION // bad quotes
  33. );
  34.  
  35. $to = 'user@example.com';
  36. // other variables ....
  37. mail($recipient, $subject, $message, $headers); // $recipient should be $to
  38.  
  39. mail('user@example.com', $subject, $message, $headers);
  40.  
  41. ini_set("mail.log", "/tmp/mail.log");
  42. ini_set("mail.add_x_header", TRUE);
  43.  
  44. <?php
  45. $name = $_POST['name'];
  46. $email = $_POST['email'];
  47. $message = $_POST['message'];
  48. $from = 'From: yoursite.com';
  49. $to = 'contact@yoursite.com';
  50. $subject = 'Customer Inquiry';
  51. $body = "From: $namen E-Mail: $emailn Message:n $message";
  52.  
  53. $headers .= "MIME-Version: 1.0rn";
  54. $headers .= "Content-type: text/htmlrn";
  55. $headers = 'From: from@example.com' . "rn" .
  56. 'Reply-To: reply@example.com' . "rn" .
  57. 'X-Mailer: PHP/' . phpversion();
  58.  
  59. mail($to, $subject, $message, $headers);
  60.  
  61. $header = "From: noreply@example.comrn";
  62. $header.= "MIME-Version: 1.0rn";
  63. $header.= "Content-Type: text/html; charset=ISO-8859-1rn";
  64. $header.= "X-Priority: 1rn";
  65.  
  66. mail($to, $subject, $message, $header);
  67.  
  68. function send_mail($email, $recipient_name, $message='')
  69. {
  70. require("phpmailer/class.phpmailer.php");
  71.  
  72. $mail = new PHPMailer();
  73.  
  74. $mail->CharSet="utf-8";
  75. $mail->IsSMTP(); // set mailer to use SMTP
  76. $mail->Host = "mail.example.com"; // specify main and backup server
  77. $mail->SMTPAuth = true; // turn on SMTP authentication
  78. $mail->Username = "myusername"; // SMTP username
  79. $mail->Password = "p@ssw0rd"; // SMTP password
  80.  
  81. $mail->From = "me@walalang.com";
  82. $mail->FromName = "System-Ad";
  83. $mail->AddAddress($email, $recipient_name);
  84.  
  85. $mail->WordWrap = 50; // set word wrap to 50 characters
  86. $mail->IsHTML(true); // set email format to HTML (true) or plain text (false)
  87.  
  88. $mail->Subject = "This is a Sampleenter code here Email";
  89. $mail->Body = $message;
  90. $mail->AltBody = "This is the body in plain text for non-HTML mail clients";
  91. $mail->AddEmbeddedImage('images/logo.png', 'logo', 'logo.png');
  92. $mail->addAttachment('files/file.xlsx');
  93.  
  94. if(!$mail->Send())
  95. {
  96. echo "Message could not be sent. <p>";
  97. echo "Mailer Error: " . $mail->ErrorInfo;
  98. exit;
  99. }
  100.  
  101. echo "Message has been sent";
  102. }
  103.  
  104. $headers = "MIME-Version: 1.0" . "rn";
  105. $headers .= "Content-type: text/html; charset=iso-8859-1" . "rn";
  106. $headers .= "From: ". $from. "rn";
  107. $headers .= "Reply-To: ". $from. "rn";
  108. $headers .= "X-Mailer: PHP/" . phpversion();
  109. $headers .= "X-Priority: 1" . "rn";
  110.  
  111. mail('email@gmail.com', $subject, $message, $headers)
  112.  
  113. $config = Array(
  114. 'protocol' => 'smtp',
  115. 'smtp_host' => 'mail.domain.com', //your smtp host
  116. 'smtp_port' => 26, //default port smtp
  117. 'smtp_user' => 'name@domain.com',
  118. 'smtp_pass' => 'password',
  119. 'mailtype' => 'html',
  120. 'charset' => 'iso-8859-1',
  121. 'wordwrap' => TRUE
  122. );
  123. $message = 'Your msg';
  124. $this->load->library('email', $config);
  125. $this->email->from('name@domain.com', 'Title');
  126. $this->email->to('emaildestination@domain.com');
  127. $this->email->subject('Header');
  128. $this->email->message($message);
  129.  
  130. if($this->email->send())
  131. {
  132. //conditional true
  133. }
  134.  
  135. <?php
  136. $name = $_POST['name'];
  137. $email = $_POST['email'];
  138. $message = $_POST['message'];
  139. $from = 'From: yoursite.com';
  140. $to = 'contact@yoursite.com';
  141. $subject = 'Customer Inquiry';
  142. $body = "From:" .$name."rn E-Mail:" .$email."rn Message:rn" .$message;
  143.  
  144. if (isset($_POST['submit']))
  145. {
  146. if (mail ($to, $subject, $body, $from))
  147. {
  148. echo '<p>Your message has been sent!</p>';
  149. }
  150. else
  151. {
  152. echo '<p>Something went wrong, go back and try again!</p>';
  153. }
  154. }
  155.  
  156. ?>
  157.  
  158. $name = $_POST['name'];
  159. $email = $_POST['email'];
  160. $reciver = '/* Reciver Email address */';
  161. if (filter_var($reciver, FILTER_VALIDATE_EMAIL)) {
  162. $subject = $name;
  163. // To send HTML mail, the Content-type header must be set.
  164. $headers = 'MIME-Version: 1.0' . "rn";
  165. $headers .= 'Content-type: text/html; charset=iso-8859-1' . "rn";
  166. $headers .= 'From:' . $email. "rn"; // Sender's Email
  167. //$headers .= 'Cc:' . $email. "rn"; // Carbon copy to Sender
  168. $template = '<div style="padding:50px; color:white;">Hello ,<br/>'
  169. . '<br/><br/>'
  170. . 'Name:' .$name.'<br/>'
  171. . 'Email:' .$email.'<br/>'
  172. . '<br/>'
  173. . '</div>';
  174. $sendmessage = "<div style="background-color:#7E7E7E; color:white;">" . $template . "</div>";
  175. // Message lines should not exceed 70 characters (PHP rule), so wrap it.
  176. $sendmessage = wordwrap($sendmessage, 70);
  177. // Send mail by PHP Mail Function.
  178. mail($reciver, $subject, $sendmessage, $headers);
  179. echo "Your Query has been received, We will contact you soon.";
  180. } else {
  181. echo "<span>* invalid email *</span>";
  182. }
  183.  
  184. try this
  185. <?php
  186. $to = "somebody@example.com, somebodyelse@example.com";
  187. $subject = "HTML email";
  188.  
  189. $message = "
  190. <html>
  191. <head>
  192. <title>HTML email</title>
  193. </head>
  194. <body>
  195. <p>This email contains HTML Tags!</p>
  196. <table>
  197. <tr>
  198. <th>Firstname</th>
  199. <th>Lastname</th>
  200. </tr>
  201. <tr>
  202. <td>John</td>
  203. <td>Doe</td>
  204. </tr>
  205. </table>
  206. </body>
  207. </html>
  208. ";
  209.  
  210. // Always set content-type when sending HTML email
  211. $headers = "MIME-Version: 1.0" . "rn";
  212. $headers .= "Content-type:text/html;charset=UTF-8" . "rn";
  213.  
  214. // More headers
  215. $headers .= 'From: <webmaster@example.com>' . "rn";
  216. $headers .= 'Cc: myboss@example.com' . "rn";
  217.  
  218. mail($to,$subject,$message,$headers);
  219. ?>
  220.  
  221. $myText = (string)$myVar;
  222.  
  223. if ($_POST['submit']) {
  224. $success= mail($to, $subject, $body, $from);
  225. if($success)
  226. {
  227. echo '
  228. <p>Your message has been sent!</p>
  229. ';
  230. } else {
  231. echo '
  232. <p>Something went wrong, go back and try again!</p>
  233. ';
  234. }
  235. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement