我使用
从gmail获取电子邮件$accountUser = 'my@mail.com';
$accountPassword = 'mypass';
$accountHost = '{imap.gmail.com:993/imap/ssl}INBOX';
$mbox = imap_open($accountHost, $accountUser, $accountPassword);
并使用
获取内容$body = imap_body($mbox , $idMensaje) ;
然后,我尝试使用PHPMailer发送相同的电子邮件,如下所示
$mail = new PHPMailer;
$mail->isSMTP();
$mail->Host = 'smtp.gmail.com';
$mail->SMTPAuth = true;
$mail->Username = $accountUser;
$mail->Password = $accountPassword;
$mail->SMTPSecure = 'tls';
$mail->Port = 587;
$mail->setFrom($accountUser, 'EMAIL');
$mail->addAddress('another@mail.com');
$mail->WordWrap = 50;
$mail->isHTML(true);
$mail->Subject = 'New Mail';
$mail->Body = $body;
if(!$mail->send()) {
echo 'Mail Error ' . $mail->ErrorInfo;
exit;
}
echo 'Mail Sended';
邮件已发送,但带有文字
--089e01494136bcca590503210698
Content-Type: multipart/alternative; boundary9e01494136bcca570503210697
--089e01494136bcca570503210697
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
... followed by the email body, everything broken and the embeded images in base64
欢迎提出任何建议,提示或建议。