我想用 php 将我的邮箱打印到我的网站

问题描述 投票:0回答:0

使用 phpmailler 检查我的电子邮件地址的邮件,并在我的网站上打印它们 有没有办法用 PHPMailer 做到这一点? 或者我该怎么做

// 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();

我试过了,但没用

php phpmailer pop3
© www.soinside.com 2019 - 2024. All rights reserved.