Specifications
}
}
}
As you can see, this function uses mail() to send the email. First, however, it loads the user’s
email address out of the database to use in the From field of the email.
Replying To or Forwarding Mail
The Reply, Reply All, and Forward functions all send mail in the same way that New Message
does. The difference in how they work is that they fill in parts of the new message form before
showing it to the user. Look back at Figure 27.8. The message we are forwarding has been
indented with the > symbol, and the Subject line prefaced with To. Similarly, the Reply and
Reply All options will fill in the recipients, subject line, and indented message.
The code to do this is activated in the body section of index.php, as follows:
case ‘reply-all’ :
{
//set cc as old cc line
if(!$imap)
$imap = open_mailbox($auth_user, $selected_account);
if($imap)
{
$header = imap_header($imap, $messageid);
if($header->reply_toaddress)
$to = $header->reply_toaddress;
else
$to = $header->fromaddress;
$cc = $header->ccaddress;
$subject = ‘Re: ‘.$header->subject;
$body = add_quoting(stripslashes(imap_body($imap, $messageid)));
imap_close($imap);
display_new_message_form($auth_user, $to, $cc, $subject, $body);
}
break;
}
case ‘reply’ :
{
//set to address as reply-to or from of the current message
if(!$imap)
$imap = open_mailbox($auth_user, $selected_account);
if($imap)
{
Building a Web-Based Email Service
C
HAPTER 27
27
BUILDING A
WEB-BASED
EMAIL
SERVICE
651
LISTING 27.12 Continued
33 7842 CH27 3/6/01 3:41 PM Page 651