Guest User

Untitled

a guest
Feb 8th, 2019
287
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 15.18 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. <form action="send_email.php" method="POST">
  42.  
  43. ini_set("mail.log", "/tmp/mail.log");
  44. ini_set("mail.add_x_header", TRUE);
  45.  
  46. $header = "From: noreply@example.comrn";
  47. $header.= "MIME-Version: 1.0rn";
  48. $header.= "Content-Type: text/html; charset=ISO-8859-1rn";
  49. $header.= "X-Priority: 1rn";
  50.  
  51. $status = mail($to, $subject, $message, $header);
  52.  
  53. if($status)
  54. {
  55. echo '<p>Your mail has been sent!</p>';
  56. } else {
  57. echo '<p>Something went wrong, Please try again!</p>';
  58. }
  59.  
  60. function send_mail($email, $recipient_name, $message='')
  61. {
  62. require("phpmailer/class.phpmailer.php");
  63.  
  64. $mail = new PHPMailer();
  65.  
  66. $mail->CharSet="utf-8";
  67. $mail->IsSMTP(); // set mailer to use SMTP
  68. $mail->Host = "mail.example.com"; // specify main and backup server
  69. $mail->SMTPAuth = true; // turn on SMTP authentication
  70. $mail->Username = "myusername"; // SMTP username
  71. $mail->Password = "p@ssw0rd"; // SMTP password
  72.  
  73. $mail->From = "me@walalang.com";
  74. $mail->FromName = "System-Ad";
  75. $mail->AddAddress($email, $recipient_name);
  76.  
  77. $mail->WordWrap = 50; // set word wrap to 50 characters
  78. $mail->IsHTML(true); // set email format to HTML (true) or plain text (false)
  79.  
  80. $mail->Subject = "This is a Sampleenter code here Email";
  81. $mail->Body = $message;
  82. $mail->AltBody = "This is the body in plain text for non-HTML mail clients";
  83. $mail->AddEmbeddedImage('images/logo.png', 'logo', 'logo.png');
  84. $mail->addAttachment('files/file.xlsx');
  85.  
  86. if(!$mail->Send())
  87. {
  88. echo "Message could not be sent. <p>";
  89. echo "Mailer Error: " . $mail->ErrorInfo;
  90. exit;
  91. }
  92.  
  93. echo "Message has been sent";
  94. }
  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. $headers = "MIME-Version: 1.0" . "rn";
  114. $headers .= "Content-type: text/html; charset=iso-8859-1" . "rn";
  115. $headers .= "From: ". $from. "rn";
  116. $headers .= "Reply-To: ". $from. "rn";
  117. $headers .= "X-Mailer: PHP/" . phpversion();
  118. $headers .= "X-Priority: 1" . "rn";
  119.  
  120. mail('email@gmail.com', $subject, $message, $headers)
  121.  
  122. <?php
  123. $SmtpServer="smtp.*.*";
  124. $SmtpPort="2525"; //default
  125. $SmtpUser="***";
  126. $SmtpPass="***";
  127. ?>
  128.  
  129. <?php
  130. class SMTPClient
  131. {
  132.  
  133. function SMTPClient ($SmtpServer, $SmtpPort, $SmtpUser, $SmtpPass, $from, $to, $subject, $body)
  134. {
  135.  
  136. $this->SmtpServer = $SmtpServer;
  137. $this->SmtpUser = base64_encode ($SmtpUser);
  138. $this->SmtpPass = base64_encode ($SmtpPass);
  139. $this->from = $from;
  140. $this->to = $to;
  141. $this->subject = $subject;
  142. $this->body = $body;
  143.  
  144. if ($SmtpPort == "")
  145. {
  146. $this->PortSMTP = 25;
  147. }
  148. else
  149. {
  150. $this->PortSMTP = $SmtpPort;
  151. }
  152. }
  153.  
  154. function SendMail ()
  155. {
  156. $newLine = "rn";
  157. $headers = "MIME-Version: 1.0" . $newLine;
  158. $headers .= "Content-type: text/html; charset=iso-8859-1" . $newLine;
  159.  
  160. if ($SMTPIN = fsockopen ($this->SmtpServer, $this->PortSMTP))
  161. {
  162. fputs ($SMTPIN, "EHLO ".$HTTP_HOST."rn");
  163. $talk["hello"] = fgets ( $SMTPIN, 1024 );
  164. fputs($SMTPIN, "auth loginrn");
  165. $talk["res"]=fgets($SMTPIN,1024);
  166. fputs($SMTPIN, $this->SmtpUser."rn");
  167. $talk["user"]=fgets($SMTPIN,1024);
  168. fputs($SMTPIN, $this->SmtpPass."rn");
  169. $talk["pass"]=fgets($SMTPIN,256);
  170. fputs ($SMTPIN, "MAIL FROM: <".$this->from.">rn");
  171. $talk["From"] = fgets ( $SMTPIN, 1024 );
  172. fputs ($SMTPIN, "RCPT TO: <".$this->to.">rn");
  173. $talk["To"] = fgets ($SMTPIN, 1024);
  174. fputs($SMTPIN, "DATArn");
  175. $talk["data"]=fgets( $SMTPIN,1024 );
  176. fputs($SMTPIN, "To: <".$this->to.">rnFrom: <".$this->from.">rn".$headers."nnSubject:".$this->subject."rnrnrn".$this->body."rn.rn");
  177. $talk["send"]=fgets($SMTPIN,256);
  178. //CLOSE CONNECTION AND EXIT ...
  179. fputs ($SMTPIN, "QUITrn");
  180. fclose($SMTPIN);
  181. //
  182. }
  183. return $talk;
  184. }
  185. }
  186. ?>
  187.  
  188. <?php
  189. include('SMTPconfig.php');
  190. include('SMTPmail.php');
  191. if($_SERVER["REQUEST_METHOD"] == "POST")
  192. {
  193. $to = "";
  194. $from = $_POST['email'];
  195. $subject = "Enquiry";
  196. $body = $_POST['name'].'</br>'.$_POST['companyName'].'</br>'.$_POST['tel'].'</br>'.'<hr />'.$_POST['message'];
  197. $SMTPMail = new SMTPClient ($SmtpServer, $SmtpPort, $SmtpUser, $SmtpPass, $from, $to, $subject, $body);
  198. $SMTPChat = $SMTPMail->SendMail();
  199. }
  200. ?>
  201.  
  202. $mail->SMTPDebug = 2;
  203.  
  204. <?php
  205. $name = $_POST['name'];
  206. $email = $_POST['email'];
  207. $message = $_POST['message'];
  208. $from = 'From: yoursite.com';
  209. $to = 'contact@yoursite.com';
  210. $subject = 'Customer Inquiry';
  211. $body = "From:" .$name."rn E-Mail:" .$email."rn Message:rn" .$message;
  212.  
  213. if (isset($_POST['submit']))
  214. {
  215. if (mail ($to, $subject, $body, $from))
  216. {
  217. echo '<p>Your message has been sent!</p>';
  218. }
  219. else
  220. {
  221. echo '<p>Something went wrong, go back and try again!</p>';
  222. }
  223. }
  224.  
  225. ?>
  226.  
  227. $config = Array(
  228. 'protocol' => 'smtp',
  229. 'smtp_host' => 'mail.domain.com', //your smtp host
  230. 'smtp_port' => 26, //default port smtp
  231. 'smtp_user' => 'name@domain.com',
  232. 'smtp_pass' => 'password',
  233. 'mailtype' => 'html',
  234. 'charset' => 'iso-8859-1',
  235. 'wordwrap' => TRUE
  236. );
  237. $message = 'Your msg';
  238. $this->load->library('email', $config);
  239. $this->email->from('name@domain.com', 'Title');
  240. $this->email->to('emaildestination@domain.com');
  241. $this->email->subject('Header');
  242. $this->email->message($message);
  243.  
  244. if($this->email->send())
  245. {
  246. //conditional true
  247. }
  248.  
  249. $name = $_POST['name'];
  250. $email = $_POST['email'];
  251. $reciver = '/* Reciver Email address */';
  252. if (filter_var($reciver, FILTER_VALIDATE_EMAIL)) {
  253. $subject = $name;
  254. // To send HTML mail, the Content-type header must be set.
  255. $headers = 'MIME-Version: 1.0' . "rn";
  256. $headers .= 'Content-type: text/html; charset=iso-8859-1' . "rn";
  257. $headers .= 'From:' . $email. "rn"; // Sender's Email
  258. //$headers .= 'Cc:' . $email. "rn"; // Carbon copy to Sender
  259. $template = '<div style="padding:50px; color:white;">Hello ,<br/>'
  260. . '<br/><br/>'
  261. . 'Name:' .$name.'<br/>'
  262. . 'Email:' .$email.'<br/>'
  263. . '<br/>'
  264. . '</div>';
  265. $sendmessage = "<div style="background-color:#7E7E7E; color:white;">" . $template . "</div>";
  266. // Message lines should not exceed 70 characters (PHP rule), so wrap it.
  267. $sendmessage = wordwrap($sendmessage, 70);
  268. // Send mail by PHP Mail Function.
  269. mail($reciver, $subject, $sendmessage, $headers);
  270. echo "Your Query has been received, We will contact you soon.";
  271. } else {
  272. echo "<span>* invalid email *</span>";
  273. }
  274.  
  275. <?php
  276. $to = "somebody@example.com, somebodyelse@example.com";
  277. $subject = "HTML email";
  278.  
  279. $message = "
  280. <html>
  281. <head>
  282. <title>HTML email</title>
  283. </head>
  284. <body>
  285. <p>This email contains HTML Tags!</p>
  286. <table>
  287. <tr>
  288. <th>Firstname</th>
  289. <th>Lastname</th>
  290. </tr>
  291. <tr>
  292. <td>John</td>
  293. <td>Doe</td>
  294. </tr>
  295. </table>
  296. </body>
  297. </html>";
  298.  
  299. // Always set content-type when sending HTML email
  300. $headers = "MIME-Version: 1.0" . "rn";
  301. $headers .= "Content-type:text/html;charset=UTF-8" . "rn";
  302.  
  303. // More headers
  304. $headers .= 'From: <webmaster@example.com>' . "rn";
  305. $headers .= 'Cc: myboss@example.com' . "rn";
  306.  
  307. mail($to,$subject,$message,$headers);
  308. ?>
  309.  
  310. if ($_POST['submit']) {
  311. $success= mail($to, $subject, $body, $from);
  312. if($success)
  313. {
  314. echo '
  315. <p>Your message has been sent!</p>
  316. ';
  317. } else {
  318. echo '
  319. <p>Something went wrong, go back and try again!</p>
  320. ';
  321. }
  322. }
  323.  
  324. require 'mail/swift_required.php';
  325.  
  326. $message = Swift_Message::newInstance()
  327. // The subject of your email
  328. ->setSubject('Jane Doe sends you a message')
  329. // The from address(es)
  330. ->setFrom(array('jane.doe@gmail.com' => 'Jane Doe'))
  331. // The to address(es)
  332. ->setTo(array('frank.stevens@gmail.com' => 'Frank Stevens'))
  333. // Here, you put the content of your email
  334. ->setBody('<h3>New message</h3><p>Here goes the rest of my message</p>', 'text/html');
  335.  
  336. if (Swift_Mailer::newInstance(Swift_MailTransport::newInstance())->send($message)) {
  337. echo json_encode([
  338. "status" => "OK",
  339. "message" => 'Your message has been sent!'
  340. ], JSON_PRETTY_PRINT);
  341. } else {
  342. echo json_encode([
  343. "status" => "error",
  344. "message" => 'Oops! Something went wrong!'
  345. ], JSON_PRETTY_PRINT);
  346. }
  347.  
  348. sudo apt-get install sendmail
  349.  
  350. require_once 'PHPMailer/PHPMailer.php';
  351. require_once '/servicios/PHPMailer/SMTP.php';
  352. require_once '/servicios/PHPMailer/Exception.php';
  353.  
  354. $mail = new PHPMailerPHPMailerPHPMailer(true);
  355. try {
  356. //Server settings
  357. $mail->SMTPDebug = 0;
  358. $mail->isSMTP();
  359. $mail->Host = 'smtp.gmail.com';
  360. $mail->SMTPAuth = true;
  361. $mail->Username = 'correo@gmail.com';
  362. $mail->Password = 'contrasenia';
  363. $mail->SMTPSecure = 'ssl';
  364. $mail->Port = 465;
  365.  
  366. //Recipients
  367. $mail->setFrom('correo@gmail.com', 'my name');
  368. $mail->addAddress('destination@correo.com');
  369.  
  370. //Attachments
  371. $mail->addAttachment('optional file'); // Add files, is optional
  372.  
  373. //Content
  374. $mail->isHTML(true);// Set email format to HTML
  375. $mail->Subject = utf8_decode("subject");
  376. $mail->Body = utf8_decode("mail content");
  377. $mail->AltBody = '';
  378. $mail->send();
  379. }
  380. catch (Exception $e){
  381. $error = $mail->ErrorInfo;
  382. }
  383.  
  384. From: myapp@example.com
  385. To: mymail@example.com
  386. Subject: Test mail via sendmail.
  387.  
  388. Text body.
  389.  
  390. root=mymail@example.com
  391. mailhub=smtp.yandex.ru:465
  392. FromLineOverride=YES
  393. UseTLS=YES
  394. AuthUser=abcde@yandex.ru
  395. AuthPass=password
  396.  
  397. $name = $_POST['name'];
  398. $email = $_POST['email'];
  399. $message = $_POST['message'];
  400. $from = 'From: yoursite.com';
  401. $to = 'contact@yoursite.com';
  402. $subject = 'Customer Inquiry';
  403. $body = "From: $namen E-Mail: $emailn Message:n $message";
  404.  
  405. <?php
  406.  
  407. error_reporting(0);
  408. $name = $_POST['name'];
  409. $email = $_POST['email'];
  410. $message = $_POST['message'];
  411. $from = 'From: yoursite.com';
  412. $to = 'contact@yoursite.com';
  413. $subject = 'Customer Inquiry';
  414. $body = "From: $namen E-Mail: $emailn Message:n $message";
  415.  
  416.  
  417. if ($_POST['submit']){
  418. if (!(empty($_POST['name']))) {
  419. if (!(empty($_POST['email']))){
  420. if (!(empty($_POST['message']))){
  421. mail ($to, $subject, $body, $from);
  422. echo '<p>Your message has been sent!</p>';
  423. }else{
  424. echo '<p>Fill your message please.</p>';}
  425. }else {
  426. echo '<p>Fill your email please.</p>';}
  427. }else{
  428. echo '<p>Fill your name please.</p>';}
  429. }else{
  430. echo '<p>Fill the form.</p>';}
  431. ?>
  432.  
  433. <html>
  434. <form method="post" action="?">
  435. <table>
  436. <tr><td>Name</td><td><input type='text' name='name' id='name'/></td></tr>
  437. <tr><td>Email</td><td><input type='text' name='email' id='email'/></td></tr>
  438. <tr><td>Message</td><td><input type='text' name='message' id='message'/></td></tr>
  439. <tr><td></td><td><input type='submit' name='submit' id='submit'/></td></tr>
  440. </table>
  441. </form>
  442. </html>
  443.  
  444. <?php
  445. $to = 'nobody@example.com';
  446. $subject = 'the subject';
  447. $message = 'hello';
  448. $headers = 'From: webmaster@example.com' . "rn" .
  449. 'Reply-To: webmaster@example.com' . "rn" .
  450. 'X-Mailer: PHP/' . phpversion();
  451.  
  452. mail($to, $subject, $message, $headers);
  453. ?>
  454.  
  455. include "libmail.php";
  456. $m = new Mail(); // create the mail
  457. $m->From( $_POST['form'] );
  458. $m->To( $_POST['to'] );
  459. $m->Subject( $_POST['subject'] );
  460. $m->Body( $_POST['body'] );
  461. $m->Cc( $_POST['cc']);
  462. $m->Priority(4);
  463. // attach a file of type image/gif to be displayed in the message if possible
  464. $m->Attach( "/home/leo/toto.gif", "image/gif", "inline" );
  465. $m->Send(); // send the mail
  466. echo "Mail was sent:"
  467. echo $m->Get(); // show the mail source
  468.  
  469. error_reporting(E_ALL);
  470.  
  471. <?php
  472. use PHPMailerPHPMailerPHPMailer;
  473. require 'PHPMailer.php';
  474. require 'SMTP.php';
  475. require 'Exception.php';
  476. $name=$_POST['name'];
  477. $mailid=$_POST['mail'];
  478. $mail = new PHPMailer;
  479. $mail->IsSMTP();
  480. $mail->SMTPDebug = 0; // Set mailer to use SMTP
  481. $mail->Host = 'smtp.gmail.com'; // Specify main and backup server
  482. $mail->Port = 587; // Set the SMTP port
  483. $mail->SMTPAuth = true; // Enable SMTP authentication
  484. $mail->Username = 'someone@gmail.com'; // SMTP username
  485. $mail->Password = 'password'; // SMTP password
  486. $mail->SMTPSecure = 'tls'; // Enable encryption, 'ssl' also accepted
  487.  
  488. $mail->From = 'someone@gmail.com';
  489. $mail->FromName = 'name';
  490. $mail->AddAddress($mailid,$name); // Name is optional
  491. $mail->IsHTML(true); // Set email format to HTML
  492. $mail->Subject = 'Here is the subject';
  493. $mail->Body = 'Here is your message' ;
  494. $mail->AltBody = 'This is the body in plain text for non-HTML mail clients';
  495. if(!$mail->Send()) {
  496. echo 'Message could not be sent.';
  497. echo 'Mailer Error: ' . $mail->ErrorInfo;
  498. exit;
  499. }
  500. echo 'Message has been sent';
  501. ?>
Add Comment
Please, Sign In to add comment