Ik gebruikte reeds een script om e-mails op te halen uit een shared mailbox.
Nu wil ik via die zelfde connectie een mail laten versturen maar hier lijkt een en ander mis te lopen?
Mails worden namelijk niet verstuurd ook al krijg ik de feedback dat dit wel zo zou moeten zijn.
Degene die er is sporadisch door geraakt komt dan veel later aan dan deze eigenlijk is verzonden...
$connection = imap_open($imap, $o365user, $pwd);
if ($connection === false) {
throw new Exception(imap_last_error());
} else {
$to = "$sendmailto";
$subject = "Test Mail";
$message = "Hello I am a <b>TEST</b> send on ".date("Y-m-d H:i:s");;
$additional_headers = "From: $portalmailnaam <$portalmailuser>\r\n" . "Reply-To: $portalmailnaam <$portalmailuser>\r\n" . "Content-type: text/html; charset=iso-8859-1\r\n";
$cc = null;
$bcc = null;
$return_path = "$portalmailuser";
if (imap_mail($to,$subject,$message,$additional_headers,$cc,$bcc,$return_path)) {
echo "Send succesful ".date("Y-m-d H:i:s");
} else {
echo "Error sending message";
}
}
imap_close($connection);Wat zie ik over het hoofd?
Alvast bedankt!
Peter