我正在开发一个离子应用程序,我需要将反馈发送到特定的电子邮件ID,因为我,使用php作为服务器端代码,我尝试了PHPMailer,以及php mail()函数但不幸的是没有任何作用...请帮我解决这个问题...
这是我的service.js
sendEmailFunction: function(feedbackUser) {
var data = {
userEmail: feedbackUser.userEmail,
feedback: feedbackUser.feedback,
sendToMail: feedbackUser.sendToMail };
var link = 'http://localhost/endpoints/sendEmail.php';
return $http.post(link, data);
}
这里是controller.js
$scope.sendFeedback = function(feedbackUser) {
AllServices.sendEmailFunction(feedbackUser)
.then(function(response) {
console.log("success");
})
.catch(function(error) {
console.log(error);
});
};
这里是.php文件
<?php
include ("connection.php");
$data = json_decode(file_get_contents("php://input"));
$userEmail = $data->userEmail;
$feedback = $data->feedback;
$sendToMail = $data->sendToMail;
$resp = array();
$to = $sendToMail;
$subject = "test anjali";
$message = $feedback;
$Header = 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$Header .= 'From: Customer <$userEmail>' . "\r\n";
ini_set('SMTP', "relay-hosting.secureserver.net");
ini_set('smtp_port', "25");
if(mail($to, $subject, $message, $Header)) {
$resp['STATUS'] = '_SUCCESS';
}
else {
$resp['STATUS'] = '_FAIL';
}
echo json_encode($resp);
?>
我不明白为什么我没有收到godaddy托管电子邮件服务的电子邮件..请帮助我....
答案 0 :(得分:1)
因为您没有连接$ userEmail。 替换这个:
$Header .= 'From: Customer <$userEmail>' . "\r\n";
有了这个:
$Header .= "From: Customer <".$userEmail.">" . "\r\n";