为什么我看不到发送邮件中的邮件或收件人没有收到任何使用php发送邮件的邮件?

时间:2015-05-17 05:51:00

标签: php email sendmail

php代码:

    //Function that create JSON to CSV format.
function ConvertToCSV(objArray) {
    var array = typeof objArray != 'object' ? JSON.parse(objArray) : objArray;

    var str = "";

    var header = "";

    header += "itemId,"
    header += "title,"
    header += "globalId,"
    header += "primaryCategory.categoryId,"
    header += "primaryCategory.categoryName,"
    header += "galleryURL,"
    header += "viewItemURL,"
    header += "paymentMethod,"
    header += "autoPay,"
    header += "location,"
    header += "country,"
    header += "shippingInfo.shippingServiceCost.currencyId,"
    header += "shippingInfo.shippingServiceCost.value," 
    header += "shippingInfo.shippingType,"
    header += "shippingInfo.shipToLocations,"
    header += "shippingInfo.expeditedShipping,"
    header += "shippingInfo.oneDayShippingAvailable,"
    header += "shippingInfo.handlingTime,"
    header += "sellingStatus.currentPrice.currencyId,"
    header += "sellingStatus.currentPrice.value,"
    header += "sellingStatus.convertedCurrentPrice.currencyId,"
    header += "sellingStatus.convertedCurrentPrice.value,"
    header += "sellingStatus.bidCount,"
    header += "sellingStatus.sellingState,"
    header += "sellingStatus.timeLeft,"
    header += "listingInfo.bestOfferEnabled,"
    header += "listingInfo.buyItNowAvailable,"
    header += "listingInfo.startTime,"
    header += "listingInfo.endTime,"
    header += "listingInfo.listingType,"
    header += "listingInfo.gift,"
    header += "returnsAccepted,"
    header += "galleryPlusPictureURL,"
    header += "condition.conditionId,"
    header += "condition.conditionDisplayName,"
    header += "isMultiVariationListing,"
    header += "topRatedListing";
    header += "\r\n";

    str  += line;

    for (var i = 0; i < array.length; i++) {
        var line = "";

        var JsonObj = array[i];
        line += JsonObj["itemId"]+",";
        line += JsonObj["title"]+",";
        line += JsonObj["globalId"]+",";

        var primaryCategory = JsonObj["primaryCategory"];
        line += primaryCategory[0]["categoryId"]+",";
        line += primaryCategory[0]["categoryName"]+",";

        line += JsonObj["galleryURL"]+",";
        line += JsonObj["viewItemURL"]+",";
        line += JsonObj["paymentMethod"]+",";
        line += JsonObj["autoPay"]+",";
        line += JsonObj["location"]+",";
        line += JsonObj["country"]+",";

        var shippingInfo = JsonObj["shippingInfo"];
        var shippingServiceCost = shippingInfo[0]["shippingServiceCost"];
        line += shippingServiceCost[0]["@currencyId"]+",";
        line += shippingServiceCost[0]["value"]+",";
        line += shippingInfo[0]["shippingType"]+",";
        line += shippingInfo[0]["shipToLocations"]+",";
        line += shippingInfo[0]["expeditedShipping"]+",";
        line += shippingInfo[0]["oneDayShippingAvailable"]+",";
        line += shippingInfo[0]["handlingTime"]+",";

        var sellingStatus = JsonObj["sellingStatus"];
        var currentPrice = sellingStatus[0]["currentPrice"];
        var convertedCurrentPrice = sellingStatus[0]["convertedCurrentPrice"];
        line += currentPrice[0]["@currencyId"]+",";
        line += currentPrice[0]["value"]+",";
        line += convertedCurrentPrice[0]["@currencyId"]+",";
        line += convertedCurrentPrice[0]["value"]+",";
        line += sellingStatus[0]["bidCount"]+",";
        line += sellingStatus[0]["sellingState"]+",";
        line += sellingStatus[0]["timeLeft"]+",";

        var listingInfo = JsonObj["listingInfo"];
        line += listingInfo[0]["bestOfferEnabled"]+",";
        line += listingInfo[0]["buyItNowAvailable"]+",";
        line += listingInfo[0]["startTime"]+",";
        line += listingInfo[0]["endTime"]+",";
        line += listingInfo[0]["listingType"]+",";
        line += listingInfo[0]["gift"]+",";
        line += JsonObj["returnsAccepted"]+",";
        line += JsonObj["galleryPlusPictureURL"]+",";

        var condition = JsonObj["condition"];
        line += condition[0]["conditionId"]+",";
        line += condition[0]["conditionDisplayName"]+",";
        line += JsonObj["isMultiVariationListing"]+",";
        line += JsonObj["topRatedListing"];

        line += '\r\n';

        str  += line;

    }

    return str;

我在gmail中启用了第二步验证。问题是由于那个,当我运行PHP代码时,我收到“发送电子邮件”。但是发送或收件人的收件箱或垃圾文件夹中没有邮件。有没有替代方法?如果是这样,请评论一步一步程序的链接,以便使用该服务发送电子邮件。

编辑:

我按照http://arpanthakrar.blogspot.in/2013/06/send-email-from-localhostwamp-server.html

中的说明设置了邮件部分

如果此方法中还有其他方法或更改,请告诉我。

1 个答案:

答案 0 :(得分:0)

让我稍微澄清一下“发送”电子邮件:

$to       = 'vickee@hotmail.com';
...
$headers  = 'From: vignesh@gmail.com' . "\r\n" .

这意味着:发送电子邮件给“vickee,来自vignesh”

不代表:“使用gmail向vickee发送电子邮件”

相反,PHP正在使用本地邮件程序来传输邮件。邮件通过您的邮箱,您的提供商MTA等传递到hotmail的vickee收件箱。

您的Gmail帐户不参与此操作。因此,查看您的Gmail帐户的“已发送”文件夹是没有意义的,而是查看受影响的收件箱。

修改

邮件的“真实”发送由本地MTA(邮件传输代理)完成。这是sendmail,postfix或任何其他本地服务。

这不是PHP的一部分或任务。

PHP仅将邮件传递给配置的MTA(通常是本地)。

因此:您需要先检查您的电子邮件设置!