-2

I am trying to generate an e-mail that will be sent to an e-mail address depending on the result. I am generating an XML document with PHP, and if the result length for the XML is 0 (meaning there was an error), I want to send it to one address. If not, I want to send it to another.

This is how I am sending the e-mail now:

$toaddress = 'mail#1@blah.com; mail#2@blah.com';
$toArray = explode(";", $toaddress);
for ($x = 0; $x < count($toArray); $x++)
{
    $mail -> AddAddress(trim($toArray[$x]));
}

This sends the e-mail to both addresses. How would I make that so that, depending on the XML result, it would send it to one or the other? Thanks.

4

2 回答 2

3

这听起来是一个非常简单的问题。我想这样的事情应该可以解决问题:

if($xmlResult) {
    $mail->AddAddress($toArray[0]);
} else {
    $mail->AddAddress($toArray[1]);
}

... where$xmlResult是您根据需要的条件设置的真/假值(您没有提供有关所需实际条件的任何信息,所以我对此无能为力)。

于 2013-06-12T15:46:01.727 回答
0

如果我理解正确,我相信您可以使用 PHP 的filesize()函数来检查文件的大小,如果大小为 0,则发送到一个地址,如果不是,则发送到另一个地址。

就像是:

$filename = 'file_name';

if (filesize($filename) === 0) {
    // send to address #1
} else {
    // send to address #2
}
于 2013-06-12T15:50:08.677 回答