Advertisement
Guest User

Untitled

a guest
Jun 20th, 2016
288
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 9.06 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. function send_mail($email, $recipient_name, $message='')
  52. {
  53. require("phpmailer/class.phpmailer.php");
  54.  
  55. $mail = new PHPMailer();
  56.  
  57. $mail->CharSet="utf-8";
  58. $mail->IsSMTP(); // set mailer to use SMTP
  59. $mail->Host = "mail.example.com"; // specify main and backup server
  60. $mail->SMTPAuth = true; // turn on SMTP authentication
  61. $mail->Username = "myusername"; // SMTP username
  62. $mail->Password = "p@ssw0rd"; // SMTP password
  63.  
  64. $mail->From = "me@walalang.com";
  65. $mail->FromName = "System-Ad";
  66. $mail->AddAddress($email, $recipient_name);
  67.  
  68. $mail->WordWrap = 50; // set word wrap to 50 characters
  69. $mail->IsHTML(true); // set email format to HTML (true) or plain text (false)
  70.  
  71. $mail->Subject = "This is a Sampleenter code here Email";
  72. $mail->Body = $message;
  73. $mail->AltBody = "This is the body in plain text for non-HTML mail clients";
  74. $mail->AddEmbeddedImage('images/logo.png', 'logo', 'logo.png');
  75. $mail->addAttachment('files/file.xlsx');
  76.  
  77. if(!$mail->Send())
  78. {
  79. echo "Message could not be sent. <p>";
  80. echo "Mailer Error: " . $mail->ErrorInfo;
  81. exit;
  82. }
  83.  
  84. echo "Message has been sent";
  85. }
  86.  
  87. $headers = "MIME-Version: 1.0" . "rn";
  88. $headers .= "Content-type: text/html; charset=iso-8859-1" . "rn";
  89. $headers .= "From: ". $from. "rn";
  90. $headers .= "Reply-To: ". $from. "rn";
  91. $headers .= "X-Mailer: PHP/" . phpversion();
  92. $headers .= "X-Priority: 1" . "rn";
  93.  
  94. mail('email@gmail.com', $subject, $message, $headers)
  95.  
  96. <?php
  97. $name = $_POST['name'];
  98. $email = $_POST['email'];
  99. $message = $_POST['message'];
  100. $from = 'From: yoursite.com';
  101. $to = 'contact@yoursite.com';
  102. $subject = 'Customer Inquiry';
  103. $body = "From: $namen E-Mail: $emailn Message:n $message";
  104.  
  105. $headers .= "MIME-Version: 1.0rn";
  106. $headers .= "Content-type: text/htmlrn";
  107. $headers = 'From: from@example.com' . "rn" .
  108. 'Reply-To: reply@example.com' . "rn" .
  109. 'X-Mailer: PHP/' . phpversion();
  110.  
  111. mail($to, $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. if ($_POST['submit']) {
  185. $success= mail($to, $subject, $body, $from);
  186. if($success)
  187. {
  188. echo '
  189. <p>Your message has been sent!</p>
  190. ';
  191. } else {
  192. echo '
  193. <p>Something went wrong, go back and try again!</p>
  194. ';
  195. }
  196. }
  197.  
  198. try this
  199. <?php
  200. $to = "somebody@example.com, somebodyelse@example.com";
  201. $subject = "HTML email";
  202.  
  203. $message = "
  204. <html>
  205. <head>
  206. <title>HTML email</title>
  207. </head>
  208. <body>
  209. <p>This email contains HTML Tags!</p>
  210. <table>
  211. <tr>
  212. <th>Firstname</th>
  213. <th>Lastname</th>
  214. </tr>
  215. <tr>
  216. <td>John</td>
  217. <td>Doe</td>
  218. </tr>
  219. </table>
  220. </body>
  221. </html>
  222. ";
  223.  
  224. // Always set content-type when sending HTML email
  225. $headers = "MIME-Version: 1.0" . "rn";
  226. $headers .= "Content-type:text/html;charset=UTF-8" . "rn";
  227.  
  228. // More headers
  229. $headers .= 'From: <webmaster@example.com>' . "rn";
  230. $headers .= 'Cc: myboss@example.com' . "rn";
  231.  
  232. mail($to,$subject,$message,$headers);
  233. ?>
  234.  
  235. $mail->SMTPDebug = 2;
  236.  
  237. $myText = (string)$myVar;
  238.  
  239. <?php
  240.  
  241. error_reporting(0);
  242. $name = $_POST['name'];
  243. $email = $_POST['email'];
  244. $message = $_POST['message'];
  245. $from = 'From: yoursite.com';
  246. $to = 'contact@yoursite.com';
  247. $subject = 'Customer Inquiry';
  248. $body = "From: $namen E-Mail: $emailn Message:n $message";
  249.  
  250.  
  251. if ($_POST['submit']){
  252. if (!(empty($_POST['name']))) {
  253. if (!(empty($_POST['email']))){
  254. if (!(empty($_POST['message']))){
  255. mail ($to, $subject, $body, $from);
  256. echo '<p>Your message has been sent!</p>';
  257. }else{
  258. echo '<p>Fill your message please.</p>';}
  259. }else {
  260. echo '<p>Fill your email please.</p>';}
  261. }else{
  262. echo '<p>Fill your name please.</p>';}
  263. }else{
  264. echo '<p>Fill the form.</p>';}
  265. ?>
  266.  
  267. <html>
  268. <form method="post" action="?">
  269. <table>
  270. <tr><td>Name</td><td><input type='text' name='name' id='name'/></td></tr>
  271. <tr><td>Email</td><td><input type='text' name='email' id='email'/></td></tr>
  272. <tr><td>Message</td><td><input type='text' name='message' id='message'/></td></tr>
  273. <tr><td></td><td><input type='submit' name='submit' id='submit'/></td></tr>
  274. </table>
  275. </form>
  276. </html>
  277.  
  278. $name = $_POST['name'];
  279. $email = $_POST['email'];
  280. $message = $_POST['message'];
  281. $from = 'From: yoursite.com';
  282. $to = 'contact@yoursite.com';
  283. $subject = 'Customer Inquiry';
  284. $body = "From: $namen E-Mail: $emailn Message:n $message";
  285.  
  286. require 'mail/swift_required.php';
  287.  
  288. $message = Swift_Message::newInstance()
  289. // The subject of your email
  290. ->setSubject('Jane Doe sends you a message')
  291. // The from address(es)
  292. ->setFrom(array('jane.doe@gmail.com' => 'Jane Doe'))
  293. // The to address(es)
  294. ->setTo(array('frank.stevens@gmail.com' => 'Frank Stevens'))
  295. // Here, you put the content of your email
  296. ->setBody('<h3>New message</h3><p>Here goes the rest of my message</p>', 'text/html');
  297.  
  298. if (Swift_Mailer::newInstance(Swift_MailTransport::newInstance())->send($message)) {
  299. echo json_encode([
  300. "status" => "OK",
  301. "message" => 'Your message has been sent!'
  302. ], JSON_PRETTY_PRINT);
  303. } else {
  304. echo json_encode([
  305. "status" => "error",
  306. "message" => 'Oops! Something went wrong!'
  307. ], JSON_PRETTY_PRINT);
  308. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement