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