Reputation: 3224
I'm building a php application that can read, reply and send emails. I use php imap to retrieve the emails. Each email has a message-id
that looks like [email protected]
. I attempted to reply to this specific message with my php application but not working. I'm using [email protected]
as mail server, i retrieve emails to my php application with php imap. Each email has a message-id, how do i reply to a specific message? How do i solve?; the below example doesn't work.
/* try to connect */
$inbox = imap_open($hostname,$username,$password) or die('Cannot connect to email: ' . imap_last_error());
/* grab emails */
$emails = imap_search($inbox,'ALL');
/* if emails are returned, cycle through each... */
if($emails) {
/* begin output var */
$output = '';
/* put the newest emails on top */
rsort($emails);
/* for every email... */
foreach($emails as $email_number) {
/* get information specific to this email */
$overview = imap_fetch_overview($inbox,$email_number,0);
$message = imap_fetchbody($inbox,$email_number,2);
$headers = "From: [email protected] \r\n";
$headers .= "Reply-To: ".$overview[0]->message_id."\r\n";
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";
$subject = "testing";
$message = "test message2";
wp_mail( $overview[0]->message_id, $subject, $message, $headers );
}
echo $output;
}
/* close the connection */
imap_close($inbox);
Upvotes: 0
Views: 976
Reputation: 31
I think you want "In-Reply-To:" instead of "Reply-To:" for the header with the message id. "Reply-To" would be an email address - who the reply should be sent to.
Upvotes: 2