Reputation: 11
Hello I am sending mail from php. I am fetching to address and cc address from database and storing them in one one variable. $to,$cc i need to use this in mailx command. Following query is hardcoded and its working.
exec('echo "hey i am there" | mailx -S smtp=10.0.8.8:25 -r [email protected] -s "Alert" [email protected]');
Need to replace
$message = hey i am there
[email protected]
$from [email protected]
$subject = Alert
exec('echo $message | mailx -S smtp=10.0.8.8:25 -r $from -s $subject $to');
But the above thing is not working
Upvotes: 0
Views: 234
Reputation: 4135
You should concatenate your strings.
exec('echo ' . $message . ' | mailx -S smtp=10.0.8.8:25 -r ' . $from . ' -s ' . $subject . ' ' . $to);
Upvotes: 2
Reputation: 13303
Just change '
to "
like
exec("echo $message | mailx -S smtp=10.0.8.8:25 -r $from -s $subject $to");
Upvotes: 4