foreach ($fwdTo as $number) { echo "<Message to=\"{$number}\">"; echo "<Body>{$fromName} > {$toName} {$body}</Body>"; for ($idx = 0; $idx < $mediaCount; ++$idx) { echo "<Media>{$_REQUEST['MediaUrl' . $idx]}</Media>"; } echo '</Message>'; } } echo '</Response>'; /* Send the email */ $mail = new PHPMailer(); $mail->isHTML(true); // Set email format to HTML $mail->setFrom($from . "@" . $messageHost, $fromName); $mail->addAddress($to . "@" . $messageHost, $toName); $mail->Subject = "{$msgType} from {$fromName}"; $msg = "<p>{$body}</p>"; for ($idx = 0; $idx < $mediaCount; ++$idx) { $mediaURL = $_REQUEST['MediaUrl' . $idx]; $mimeType = $_REQUEST['MediaContentType' . $idx]; $cid = $_REQUEST['MessageSid'] . '-' . $idx; $filename = $cid . '.' . $extensionMap[$mimeType]; $mail->AddStringEmbeddedImage(file_get_contents($mediaURL), $cid, $filename, 'base64', $mimeType); $msg .= "<img src=\"cid:{$cid}\" /><br/>"; } $mail->Body = $msg; if (!$mail->send()) { echo 'Message could not be sent.'; echo 'Mailer Error: ' . $mail->ErrorInfo; }