postfix send email subject breaks the FROM

Question!

I am using postfix to send an email to the user, but the problem is it breaks the words where it finds the space. Here is the screenshot: postfix-send-email

enter image description here PHP code to send an email:

<?php
$subject = "Status Of mail";
$message = "Test Email using Postfix Apache2";
$headers  = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$headers .= 'From: 'The Travel Worthy' '[email protected]"\r\n";
$send = mail('[email protected]', $subject, $message, $headers);
if($send)
{
    return 1;
}
else
{
    return 0;
}
?>


Answers

Try replacing

$headers .= 'From: 'The Travel Worthy' '[email protected]"\r\n";

with

$headers .= "From: The Travel Worthy <[email protected]>\r\n";
By : Nabeel


You can push all the resp in list array and send after completing loop.

Like this:

    exports.getrequestsdetails = function(req, res) {
    var params = req.params;
    console.log(params);

    var record = db.collection('requests');
    var item = {
        "sent_id": params.id,
        "status": 1
    };

    record.find(item).toArray((err, result) => {
        if (err) {
            return err;
        }
        if (result) {
            var list = [];
            for (var i in result) {
                var id = result[i].recieved_id;
                var profile = db.collection('profile');
                profile.find({
                    '_id': new ObjectId(id)
                }).toArray((err, resp) => {
                    if (err) {
                        return err;
                    }
                    else{
                        list.push(resp);
                        console.log(resp);
                        if(i===result[result.length-1]){
                             res.send(list);
                        }
                    }
                });
            }

        } //end of if loop
        else {
            response = {
                status: 'fail',
                data: []
            };
        }

    });
};

Hope this work for you



Don't use for loop in asynchronous mode. Use async module instead like below.

var async = require('async');
exports.getrequestsdetails = function (req, res) {
    var params = req.params;
    console.log(params)
    var record = db.collection('requests');
    var item = {
        "sent_id": params.id,
        "status": 1
    }
    record.find(item).toArray(function (err, result) {
        if (err) {
            return
        }
        if (result) {
            var list = [];
            async.each(result, function (item, cb) {
                var id = item.recieved_id;
                var profile = db.collection('profile');
                profile.findOne({
                    '_id': new ObjectId(id)
                }, function (err, resp) {
                    if (err) {
                        return cb();
                    }
                    if (resp) {
                        list.push(resp);
                        console.log(resp);
                        return  cb();
                    }
                    return cb();
                });
            }, function (err) {
                res.send(list);
            });
        }//end of if loop
        else {
            response = {
                status: 'fail',
                data: []
            };
        }

    });

}
By : Sham


This video can help you solving your question :)
By: admin