Advertisement
Guest User

Untitled

a guest
Oct 4th, 2015
174
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. $header = "From: noreply@example.comrn";
  45. $header.= "MIME-Version: 1.0rn";
  46. $header.= "Content-Type: text/html; charset=ISO-8859-1rn";
  47. $header.= "X-Priority: 1rn";
  48.  
  49. mail($to, $subject, $message, $header);
  50.  
  51. <?php
  52. $name = $_POST['name'];
  53. $email = $_POST['email'];
  54. $message = $_POST['message'];
  55. $from = 'From: yoursite.com';
  56. $to = 'contact@yoursite.com';
  57. $subject = 'Customer Inquiry';
  58. $body = "From: $namen E-Mail: $emailn Message:n $message";
  59.  
  60. $headers .= "MIME-Version: 1.0rn";
  61. $headers .= "Content-type: text/htmlrn";
  62. $headers = 'From: from@example.com' . "rn" .
  63. 'Reply-To: reply@example.com' . "rn" .
  64. 'X-Mailer: PHP/' . phpversion();
  65.  
  66. mail($to, $subject, $message, $headers);
  67.  
  68. $name = $_POST['name'];
  69. $email = $_POST['email'];
  70. $reciver = '/* Reciver Email address */';
  71. if (filter_var($reciver, FILTER_VALIDATE_EMAIL)) {
  72. $subject = $name;
  73. // To send HTML mail, the Content-type header must be set.
  74. $headers = 'MIME-Version: 1.0' . "rn";
  75. $headers .= 'Content-type: text/html; charset=iso-8859-1' . "rn";
  76. $headers .= 'From:' . $email. "rn"; // Sender's Email
  77. //$headers .= 'Cc:' . $email. "rn"; // Carbon copy to Sender
  78. $template = '<div style="padding:50px; color:white;">Hello ,<br/>'
  79. . '<br/><br/>'
  80. . 'Name:' .$name.'<br/>'
  81. . 'Email:' .$email.'<br/>'
  82. . '<br/>'
  83. . '</div>';
  84. $sendmessage = "<div style="background-color:#7E7E7E; color:white;">" . $template . "</div>";
  85. // Message lines should not exceed 70 characters (PHP rule), so wrap it.
  86. $sendmessage = wordwrap($sendmessage, 70);
  87. // Send mail by PHP Mail Function.
  88. mail($reciver, $subject, $sendmessage, $headers);
  89. echo "Your Query has been received, We will contact you soon.";
  90. } else {
  91. echo "<span>* invalid email *</span>";
  92. }
  93.  
  94. try this
  95. <?php
  96. $to = "somebody@example.com, somebodyelse@example.com";
  97. $subject = "HTML email";
  98.  
  99. $message = "
  100. <html>
  101. <head>
  102. <title>HTML email</title>
  103. </head>
  104. <body>
  105. <p>This email contains HTML Tags!</p>
  106. <table>
  107. <tr>
  108. <th>Firstname</th>
  109. <th>Lastname</th>
  110. </tr>
  111. <tr>
  112. <td>John</td>
  113. <td>Doe</td>
  114. </tr>
  115. </table>
  116. </body>
  117. </html>
  118. ";
  119.  
  120. // Always set content-type when sending HTML email
  121. $headers = "MIME-Version: 1.0" . "rn";
  122. $headers .= "Content-type:text/html;charset=UTF-8" . "rn";
  123.  
  124. // More headers
  125. $headers .= 'From: <webmaster@example.com>' . "rn";
  126. $headers .= 'Cc: myboss@example.com' . "rn";
  127.  
  128. mail($to,$subject,$message,$headers);
  129. ?>
  130.  
  131. function send_mail($email, $recipient_name, $message='')
  132. {
  133. require("phpmailer/class.phpmailer.php");
  134.  
  135. $mail = new PHPMailer();
  136.  
  137. $mail->CharSet="utf-8";
  138. $mail->IsSMTP(); // set mailer to use SMTP
  139. $mail->Host = "mail.example.com"; // specify main and backup server
  140. $mail->SMTPAuth = true; // turn on SMTP authentication
  141. $mail->Username = "myusername"; // SMTP username
  142. $mail->Password = "p@ssw0rd"; // SMTP password
  143.  
  144. $mail->From = "me@walalang.com";
  145. $mail->FromName = "System-Ad";
  146. $mail->AddAddress($email, $recipient_name);
  147.  
  148. $mail->WordWrap = 50; // set word wrap to 50 characters
  149. $mail->IsHTML(true); // set email format to HTML (true) or plain text (false)
  150.  
  151. $mail->Subject = "This is a Sampleenter code here Email";
  152. $mail->Body = $message;
  153. $mail->AltBody = "This is the body in plain text for non-HTML mail clients";
  154. $mail->AddEmbeddedImage('images/logo.png', 'logo', 'logo.png');
  155. $mail->addAttachment('files/file.xlsx');
  156.  
  157. if(!$mail->Send())
  158. {
  159. echo "Message could not be sent. <p>";
  160. echo "Mailer Error: " . $mail->ErrorInfo;
  161. exit;
  162. }
  163.  
  164. echo "Message has been sent";
  165. }
  166.  
  167. $config = Array(
  168. 'protocol' => 'smtp',
  169. 'smtp_host' => 'mail.domain.com', //your smtp host
  170. 'smtp_port' => 26, //default port smtp
  171. 'smtp_user' => 'name@domain.com',
  172. 'smtp_pass' => 'password',
  173. 'mailtype' => 'html',
  174. 'charset' => 'iso-8859-1',
  175. 'wordwrap' => TRUE
  176. );
  177. $message = 'Your msg';
  178. $this->load->library('email', $config);
  179. $this->email->from('name@domain.com', 'Title');
  180. $this->email->to('emaildestination@domain.com');
  181. $this->email->subject('Header');
  182. $this->email->message($message);
  183.  
  184. if($this->email->send())
  185. {
  186. //conditional true
  187. }
  188.  
  189. <?php
  190. $name = $_POST['name'];
  191. $email = $_POST['email'];
  192. $message = $_POST['message'];
  193. $from = 'From: yoursite.com';
  194. $to = 'contact@yoursite.com';
  195. $subject = 'Customer Inquiry';
  196. $body = "From:" .$name."rn E-Mail:" .$email."rn Message:rn" .$message;
  197.  
  198. if (isset($_POST['submit']))
  199. {
  200. if (mail ($to, $subject, $body, $from))
  201. {
  202. echo '<p>Your message has been sent!</p>';
  203. }
  204. else
  205. {
  206. echo '<p>Something went wrong, go back and try again!</p>';
  207. }
  208. }
  209.  
  210. ?>
  211.  
  212. $headers = "MIME-Version: 1.0" . "rn";
  213. $headers .= "Content-type: text/html; charset=iso-8859-1" . "rn";
  214. $headers .= "From: ". $from. "rn";
  215. $headers .= "Reply-To: ". $from. "rn";
  216. $headers .= "X-Mailer: PHP/" . phpversion();
  217. $headers .= "X-Priority: 1" . "rn";
  218.  
  219. mail('email@gmail.com', $subject, $message, $headers)
  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