xxxxxxxxxx
//docs
https://www.php.net/manual/en/book.imap.php
https://garrettstjohn.com/articles/reading-email-php/
xxxxxxxxxx
<?php
ini_set( 'display_errors', 1 );
error_reporting( E_ALL );
$from = "test@hostinger-tutorials.com";
$to = "test@hostinger.com";
$subject = "Checking PHP mail";
$message = "PHP mail works just fine";
$headers = "From:" . $from;
if(mail($to,$subject,$message, $headers)) {
echo "The email message was sent.";
} else {
echo "The email message was not sent.";
}
xxxxxxxxxx
<?php
$name = $_POST["name"];
$email = $_POST["email"];
$subject = $_POST["subject"];
$message = $_POST["message"];
require "vendor/autoload.php";
use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\SMTP;
$mail = new PHPMailer(true);
// $mail->SMTPDebug = SMTP::DEBUG_SERVER;
$mail->isSMTP();
$mail->SMTPAuth = true;
$mail->Host = "smtp.example.com";
$mail->SMTPSecure = PHPMailer::ENCRYPTION_STARTTLS;
$mail->Port = 587;
$mail->Username = "you@example.com";
$mail->Password = "password";
$mail->setFrom($email, $name);
$mail->addAddress("dave@example.com", "Dave");
$mail->Subject = $subject;
$mail->Body = $message;
$mail->send();
header("Location: sent.html");
xxxxxxxxxx
<?php
function strip_crlf($string)
{
return str_replace("\r\n", "", $string);
}
if (! empty($_POST["send"])) {
$name = $_POST["userName"];
$email = $_POST["userEmail"];
$subject = $_POST["subject"];
$content = $_POST["content"];
$toEmail = "admin@phppot_samples.com";
// CRLF Injection attack protection
$name = strip_crlf($name);
$email = strip_crlf($email);
if (! filter_var($email, FILTER_VALIDATE_EMAIL)) {
echo "The email address is invalid.";
} else {
// appending \r\n at the end of mailheaders for end
$mailHeaders = "From: " . $name . "<" . $email . ">\r\n";
if (mail($toEmail, $subject, $content, $mailHeaders)) {
$message = "Your contact information is received successfully.";
$type = "success";
}
}
}
require_once "contact-view.php";
?>
xxxxxxxxxx
//Using Cpanel from StackOverflow
$socket = fsockopen($cpdomain,2082);
$cuser = "YourUserName";
$cpassword = "YourPassword";
$authstr = base64_encode("".$cpuser.":".$cppass."");
$in = "GET /frontend/$cpskin/mail/doaddpop.html?email=$euser&$edomain&password=$epass"a=$equota
HTTP/1.0\r\nAuthorization: Basic $authstr \r\n";
fputs($socket,$in);
fclose( $socket );
xxxxxxxxxx
mail ( string $to , string $subject , string $message [, mixed $additional_headers [, string $additional_parameters ]] ) : bool