Guest User

Untitled

a guest
Feb 2nd, 2018
414
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.50 KB | None | 0 0
  1. require_once "Mail.php";
  2.  
  3. $from = "FPM <forms@fpmofames.com>";
  4. $from_name = "FPM";
  5.  
  6. $host = "localhost";
  7. $username = "username";
  8. $password = "password";
  9.  
  10. $subject = "Subject";
  11. $message = "Message";
  12.  
  13. $to = "<example@example.com>";
  14. $headers = array ('From' => $from,
  15. 'To' => $to,
  16. 'Subject' => $subject,
  17. 'MIME-Version' => '1.0',
  18. 'Content-Type' => "text/html; charset=ISO-8859-1"
  19. );
  20.  
  21. $smtp = Mail::factory('smtp',
  22. array ('host' => $host,
  23. 'auth' => true,
  24. 'username' => $username,
  25. 'password' => $password));
  26.  
  27. $mail = $smtp->send($to, $headers, $message);
  28.  
  29. <?php
  30. require_once "Mail.php";
  31. $url = $_GET['baseUrl']; // source url
  32. $success = false;
  33. $senderName = isset( $_GET['txtname'] ) ? preg_replace( "/[^.-' a-zA-Z0-9]/", "", $_GET['txtname'] ) : "";
  34. $senderEmail = isset( $_GET['txtemail'] ) ? preg_replace( "/[^.-_@a-zA-Z0-9]/", "", $_GET['txtemail'] ) : "";
  35. $msg = isset( $_GET['txtDesc'] ) ? preg_replace( "/(From:|To:|BCC:|CC:|Subject:|Content-Type:)/", "", $_GET['txtDesc'] ) : "";
  36. $body = '<table width="400" border="0">
  37. <tr>
  38. <th scope="col">Name:</th>
  39. <th scope="col">'.$senderName.'</th>
  40. </tr>
  41. <tr>
  42. <th scope="col">Company:</th>
  43. <td scope="col">'.$_GET['txtCompany'].'</td>
  44. </tr>
  45. <tr>
  46. <th scope="row">Phone:</th>
  47. <td>'.$_GET['txtphone'].'</td>
  48. </tr>
  49. <tr>
  50. <th scope="row">E-mail:</th>
  51. <td>'.$senderEmail.'</td>
  52. </tr>
  53. <tr>
  54. <th scope="row">URL:</th>
  55. <td>'.$url.'</td>
  56. </tr>
  57. <tr>
  58. <th scope="row">Massage:</th>
  59. <td>'.$msg.'</td>
  60. </tr>
  61. </table>';
  62.  
  63. $from = $senderName."<".$senderEmail.">";
  64. $to = "Contact ManagerHR<info@aequitas-infotech.com>";
  65. $subject = "Hi!";
  66. $host = "XXX.host.com";
  67. $username = "username@host.com";
  68. $password = "*****";
  69. /* MIME-Version should be "1.0rn" and Content-Type should be "text/html; charset=ISO-8859-1rn" to send an HTML Email */
  70. $headers = array ('MIME-Version' => '1.0rn',
  71. 'Content-Type' => "text/html; charset=ISO-8859-1rn",
  72. 'From' => $from,
  73. 'To' => $to,
  74. 'Subject' => $subject
  75. );
  76. $smtp = Mail::factory('smtp',
  77. array ('host' => $host,
  78. 'auth' => true,
  79. 'username' => $username,
  80. 'password' => $password));
  81. $mail = $smtp->send($to, $headers, $body);
  82. if (PEAR::isError($mail)) {
  83. echo("<p>" . $mail->getMessage() . "</p>");
  84. } else {
  85. header('Location: '.$url); // redirect to url where from inquiry made
  86. //echo("<p>Message successfully sent!</p>");
  87. }
  88. ?>
  89.  
  90. $crlf = "n";
  91. // Creating the Mime message
  92. $mime = new Mail_mime($crlf);
  93.  
  94. // Setting the body of the email
  95. $mime->setTXTBody($text);
  96. $mime->setHTMLBody($html);
  97. ...
  98. $body = $mime->get();
  99.  
  100. Hi developers you can complete in two steps
  101. Step 1: put code in your file
  102.  
  103. <?php
  104. require 'PHPMailerAutoload.php';
  105.  
  106. $mail = new PHPMailer;
  107.  
  108. //$mail->SMTPDebug = 3; // Enable verbose debug output
  109.  
  110. $mail->isSMTP(); // Set mailer to use SMTP
  111. $mail->Host = 'smtp.gmail.com'; // Specify main and backup SMTP servers
  112. $mail->SMTPAuth = true; // Enable SMTP authentication
  113. $mail->Username = 'user@example.com'; // SMTP username
  114. $mail->Password = 'secret'; // SMTP password
  115. $mail->SMTPSecure = 'tls'; // Enable TLS encryption, `ssl` also accepted
  116. $mail->Port = 587; // TCP port to connect to
  117.  
  118. $mail->setFrom('from@example.com', 'Mailer');
  119. $mail->addAddress('joe@example.net', 'Joe User'); // Add a recipient
  120. $mail->addAddress('ellen@example.com'); // Name is optional
  121. $mail->addReplyTo('info@example.com', 'Information');
  122. $mail->addCC('cc@example.com');
  123. $mail->addBCC('bcc@example.com');
  124.  
  125. $mail->addAttachment('/var/tmp/file.tar.gz'); // Add attachments
  126. $mail->addAttachment('/tmp/image.jpg', 'new.jpg'); // Optional name
  127. $mail->isHTML(true); // Set email format to HTML
  128.  
  129. $mail->Subject = 'Here is the subject';
  130. $mail->Body = 'This is the HTML message body <b>in bold!</b>';
  131. $mail->AltBody = 'This is the body in plain text for non-HTML mail clients';
  132.  
  133. if(!$mail->send()) {
  134. echo 'Message could not be sent.';
  135. echo 'Mailer Error: ' . $mail->ErrorInfo;
  136. } else {
  137. echo 'Message has been sent';
  138. }
  139.  
  140.  
  141. Step:2 Download this included file in given URL.
  142. Url: https://github.com/PHPMailer/PHPMailer.git
  143.  
  144. and click on **clone or download** button
  145. and set folder your system.
Add Comment
Please, Sign In to add comment