Guest User

Untitled

a guest
Jul 19th, 2018
2,049
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 9.78 KB | None | 0 0
  1. <?php
  2. $to = 'nobody@example.com';
  3. $subject = 'the subject';
  4. $message = 'hello';
  5. $headers = 'From: webmaster@example.com' . "rn" .
  6. 'Reply-To: webmaster@example.com' . "rn" .
  7. 'X-Mailer: PHP/' . phpversion();
  8.  
  9. mail($to, $subject, $message, $headers);
  10. ?>
  11.  
  12. <?php
  13. require 'PHPMailerAutoload.php';
  14.  
  15. $mail = new PHPMailer;
  16.  
  17. $mail->isSMTP(); // Set mailer to use SMTP
  18. $mail->Host = 'smtp1.example.com;smtp2.example.com'; // Specify main and backup SMTP servers
  19. $mail->SMTPAuth = true; // Enable SMTP authentication
  20. $mail->Username = 'user@example.com'; // SMTP username
  21. $mail->Password = 'secret'; // SMTP password
  22. $mail->SMTPSecure = 'tls'; // Enable encryption, 'ssl' also accepted
  23.  
  24. $mail->From = 'from@example.com';
  25. $mail->FromName = 'Mailer';
  26. $mail->addAddress('joe@example.net', 'Joe User'); // Add a recipient
  27. $mail->addAddress('ellen@example.com'); // Name is optional
  28. $mail->addReplyTo('info@example.com', 'Information');
  29. $mail->addCC('cc@example.com');
  30. $mail->addBCC('bcc@example.com');
  31.  
  32. $mail->WordWrap = 50; // Set word wrap to 50 characters
  33. $mail->addAttachment('/var/tmp/file.tar.gz'); // Add attachments
  34. $mail->addAttachment('/tmp/image.jpg', 'new.jpg'); // Optional name
  35. $mail->isHTML(true); // Set email format to HTML
  36.  
  37. $mail->Subject = 'Here is the subject';
  38. $mail->Body = 'This is the HTML message body <b>in bold!</b>';
  39. $mail->AltBody = 'This is the body in plain text for non-HTML mail clients';
  40.  
  41. if(!$mail->send()) {
  42. echo 'Message could not be sent.';
  43. echo 'Mailer Error: ' . $mail->ErrorInfo;
  44. } else {
  45. echo 'Message has been sent';
  46. }
  47.  
  48. // multiple recipients
  49. $to = 'aidan@example.com' . ', '; // note the comma
  50. $to .= 'wez@example.com';
  51.  
  52. // subject
  53. $subject = 'Birthday Reminders for August';
  54.  
  55. // message
  56. $message = '
  57. <html>
  58. <head>
  59. <title>Birthday Reminders for August</title>
  60. </head>
  61. <body>
  62. <p>Here are the birthdays upcoming in August!</p>
  63. <table>
  64. <tr>
  65. <th>Person</th><th>Day</th><th>Month</th><th>Year</th>
  66. </tr>
  67. <tr>
  68. <td>Joe</td><td>3rd</td><td>August</td><td>1970</td>
  69. </tr>
  70. <tr>
  71. <td>Sally</td><td>17th</td><td>August</td><td>1973</td>
  72. </tr>
  73. </table>
  74. </body>
  75. </html>
  76. ';
  77.  
  78. // To send HTML mail, the Content-type header must be set
  79. $headers = 'MIME-Version: 1.0' . "rn";
  80. $headers .= 'Content-type: text/html; charset=iso-8859-1' . "rn";
  81.  
  82. // Additional headers
  83. $headers .= 'To: Mary <mary@example.com>, Kelly <kelly@example.com>' . "rn";
  84. $headers .= 'From: Birthday Reminder <birthday@example.com>' . "rn";
  85. $headers .= 'Cc: birthdayarchive@example.com' . "rn";
  86. $headers .= 'Bcc: birthdaycheck@example.com' . "rn";
  87.  
  88. // Mail it
  89. mail($to, $subject, $message, $headers);
  90.  
  91. <?php
  92. include('Mail.php');
  93.  
  94. $recipients = 'joe@example.com';
  95.  
  96. $headers['From'] = 'richard@example.com';
  97. $headers['To'] = 'joe@example.com';
  98. $headers['Subject'] = 'Test message';
  99.  
  100. $body = 'Test message';
  101.  
  102. $smtpinfo["host"] = "smtp.server.com";
  103. $smtpinfo["port"] = "25";
  104. $smtpinfo["auth"] = true;
  105. $smtpinfo["username"] = "smtp_user";
  106. $smtpinfo["password"] = "smtp_password";
  107.  
  108.  
  109. // Create the mail object using the Mail::factory method
  110. $mail_object =& Mail::factory("smtp", $smtpinfo);
  111.  
  112. $mail_object->send($recipients, $headers, $body);
  113. ?>
  114.  
  115. require 'mail/swift_required.php';
  116.  
  117. $message = Swift_Message::newInstance()
  118. // The subject of your email
  119. ->setSubject('Jane Doe sends you a message')
  120. // The from address(es)
  121. ->setFrom(array('jane.doe@gmail.com' => 'Jane Doe'))
  122. // The to address(es)
  123. ->setTo(array('frank.stevens@gmail.com' => 'Frank Stevens'))
  124. // Here, you put the content of your email
  125. ->setBody('<h3>New message</h3><p>Here goes the rest of my message</p>', 'text/html');
  126.  
  127. if (Swift_Mailer::newInstance(Swift_MailTransport::newInstance())->send($message)) {
  128. echo json_encode([
  129. "status" => "OK",
  130. "message" => 'Your message has been sent!'
  131. ], JSON_PRETTY_PRINT);
  132. } else {
  133. echo json_encode([
  134. "status" => "error",
  135. "message" => 'Oops! Something went wrong!'
  136. ], JSON_PRETTY_PRINT);
  137. }
  138.  
  139. <?php
  140. $to = "somebody@example.com";
  141. $subject = "My subject";
  142. $txt = "Hello world!";
  143. $headers = "From: webmaster@example.com" . "rn" .
  144. "CC: somebodyelse@example.com";
  145.  
  146. mail($to,$subject,$txt,$headers);
  147. ?>
  148.  
  149. <?php
  150. $to = 'SomeOtherEmailAddress@Domain.com';
  151. $subject = 'This is subject';
  152. $message = 'This is body of email';
  153. $from = "From: FirstName LastName <SomeEmailAddress@Domain.com>";
  154. mail($to,$subject,$message,$from);
  155.  
  156. <?php
  157. // Multiple recipients
  158. $to = 'johny@example.com, sally@example.com'; // note the comma
  159.  
  160. // Subject
  161. $subject = 'Birthday Reminders for August';
  162.  
  163. // Message
  164. $message = '
  165. <html>
  166. <head>
  167. <title>Birthday Reminders for August</title>
  168. </head>
  169. <body>
  170. <p>Here are the birthdays upcoming in August!</p>
  171. <table>
  172. <tr>
  173. <th>Person</th><th>Day</th><th>Month</th><th>Year</th>
  174. </tr>
  175. <tr>
  176. <td>Johny</td><td>10th</td><td>August</td><td>1970</td>
  177. </tr>
  178. <tr>
  179. <td>Sally</td><td>17th</td><td>August</td><td>1973</td>
  180. </tr>
  181. </table>
  182. </body>
  183. </html>
  184. ';
  185.  
  186. // To send HTML mail, the Content-type header must be set
  187. $headers[] = 'MIME-Version: 1.0';
  188. $headers[] = 'Content-type: text/html; charset=iso-8859-1';
  189.  
  190. // Additional headers
  191. $headers[] = 'To: Mary <mary@example.com>, Kelly <kelly@example.com>';
  192. $headers[] = 'From: Birthday Reminder <birthday@example.com>';
  193. $headers[] = 'Cc: birthdayarchive@example.com';
  194. $headers[] = 'Bcc: birthdaycheck@example.com';
  195.  
  196. // Mail it
  197. mail($to, $subject, $message, implode("rn", $headers));
  198. ?>
  199.  
  200. require_once('class.smtp.php');
  201. require_once('class.phpmailer.php');
  202.  
  203. require_once('class.smtp.php');
  204. require_once('class.phpmailer.php');
  205. ...
  206. //----------------------------------------------
  207. // Send an e-mail. Returns true if successful
  208. //
  209. // $to - destination
  210. // $nameto - destination name
  211. // $subject - e-mail subject
  212. // $message - HTML e-mail body
  213. // altmess - text alternative for HTML.
  214. //----------------------------------------------
  215. function sendmail($to,$nameto,$subject,$message,$altmess) {
  216.  
  217. $from = "yourcontact@yourdomain.com"
  218. $namefrom = "yourname";
  219. $mail = new PHPMailer();
  220. $mail->CharSet = 'UTF-8';
  221. $mail->isSMTP(); // by SMTP
  222. $mail->SMTPAuth = true; // user and password
  223. $mail->Host = "localhost";
  224. $mail->Port = 25;
  225. $mail->Username = $from;
  226. $mail->Password = "yourpassword";
  227. $mail->SMTPSecure = ""; // options: 'ssl', 'tls' , ''
  228. $mail->setFrom($from,$namefrom); // From (origin)
  229. $mail->addCC($from,$namefrom); // There is also addBCC
  230. $mail->Subject = $subject;
  231. $mail->AltBody = $altmess;
  232. $mail->Body = $message;
  233. $mail->isHTML(); // Set HTML type
  234. //$mail->addAttachment("attachment");
  235. $mail->addAddress($to, $nameto);
  236. return $mail->send();
  237. }
  238.  
  239. <h2>Test Mail</h2>
  240. <?php
  241.  
  242. if (!isset($_POST["submit"]))
  243. {
  244. ?>
  245. <form method="post" action="<?php echo $_SERVER["PHP_SELF"];?>">
  246. From: <input type="text" name="from"><br>
  247. Subject: <input type="text" name="subject"><br>
  248. Message: <textarea rows="10" cols="40" name="message"></textarea><br>
  249. <input type="submit" name="submit" value="Click To send mail">
  250. </form>
  251. <?php
  252. }
  253.  
  254. else
  255.  
  256. {
  257.  
  258. if (isset($_POST["from"]))
  259. {
  260. $from = $_POST["from"]; // sender
  261. $subject = $_POST["subject"];
  262. $message = $_POST["message"];
  263.  
  264. $message = wordwrap($message, 70);
  265.  
  266. mail("Test@example.com",$subject,$message,"From: $fromn");
  267. echo "Thank you for sending an email";
  268. }
  269. }
  270. ?>
  271.  
  272. <?php
  273. include "db_conn.php";//connection file
  274. require "PHPMailerAutoload.php";// it will be in PHPMailer
  275. require "class.smtp.php";// it will be in PHPMailer
  276. require "class.phpmailer.php";// it will be in PHPMailer
  277.  
  278.  
  279. $response = array();
  280. $params = json_decode(file_get_contents("php://input"));
  281.  
  282. if(!empty($params->email_id)){
  283.  
  284. $email_id = $params->email_id;
  285. $flag=false;
  286. echo "something";
  287. if(!filter_var($email_id, FILTER_VALIDATE_EMAIL))
  288. {
  289. $response['ERROR']='EMAIL address format error';
  290. echo json_encode($response,JSON_UNESCAPED_SLASHES);
  291. return;
  292. }
  293. $sql="SELECT * from sales where email_id ='$email_id' ";
  294.  
  295. $result = mysqli_query($conn,$sql);
  296. $count = mysqli_num_rows($result);
  297.  
  298. $to = "demo@gmail.com";
  299. $subject = "DEMO Subject";
  300. $messageBody ="demo message .";
  301.  
  302. if($count ==0){
  303. $response["valid"] = false;
  304. $response["message"] = "User is not registered yet";
  305. echo json_encode($response);
  306. return;
  307. }
  308.  
  309. else {
  310.  
  311. $mail = new PHPMailer();
  312. $mail->IsSMTP();
  313. $mail->SMTPAuth = true; // authentication enabled
  314. $mail->IsHTML(true);
  315. $mail->SMTPSecure = 'ssl';//turn on to send html email
  316. // $mail->Host = "ssl://smtp.zoho.com";
  317. $mail->Host = "p3plcpnl0749.prod.phx3.secureserver.net";//you can use gmail
  318. $mail->Port = 465;
  319. $mail->Username = "demousername@example.com";
  320. $mail->Password = "demopassword";
  321. $mail->SetFrom("demousername@example.com", "Any demo alert");
  322. $mail->Subject = $subject;
  323.  
  324. $mail->Body = $messageBody;
  325. $mail->AddAddress($to);
  326. echo "yes";
  327.  
  328. if(!$mail->send()) {
  329. echo "Mailer Error: " . $mail->ErrorInfo;
  330. }
  331. else {
  332. echo "Message has been sent successfully";
  333. }
  334. }
  335.  
  336. }
  337. else{
  338. $response["valid"] = false;
  339. $response["message"] = "Required field(s) missing";
  340. echo json_encode($response);
  341. }
  342.  
  343.  
  344. ?>
  345.  
  346. <?php
  347. // the message
  348. $msg = "First line of textnSecond line of text";
  349.  
  350. // use wordwrap() if lines are longer than 70 characters
  351. $msg = wordwrap($msg,70);
  352.  
  353. // send email
  354. mail("someone@example.com","My subject",$msg);
  355.  
  356. ?>
Add Comment
Please, Sign In to add comment