MR KİNG
MR KİNG

Reputation: 1

I want to print my email box to my website with php

Checking the mails to my e-mail address with phpmailler, and printing them on my website Is there a way to do it with PHPMailer? Or how can I do

// include necessary files
require_once "PHPMailer/PHPMailer.php";
require_once "PHPMailer/Exception.php";
require_once "PHPMailer/POP3.php";

// set email configurations
$hostname = 'mail.mydomin.com'; // email server address
$username = '[email protected]'; // email address
$password = 'password'; // email password

// connect to email server
$pop3 = new POP3();
$pop3->connect($hostname);
$pop3->login($username, $password);

// get emails from inbox
$emails = $pop3->getListing();

// print email headers and contents
if($emails) {
foreach($emails as $email_number => $email_header) {
$subject = $email_header->subject;
$from = $email_header->from;
$body = $pop3->getRawListing($email_number);
echo "Subject: ".$subject."<br>";
echo "From: ".$from."<br>";
echo "Body: ".$body."<br>";
}
}

// close the email connection
$pop3->disconnect();

i tried this but it didn't work

Upvotes: 0

Views: 24

Answers (0)

Related Questions