![](/img/trans.png)
[英]how to attach multiple files to email and send it to multiple emailid dynamically php
[英]how to send email to godaddy hosted emailid using PHP and angularjs
我正在开发一个离子应用程序,在其中我需要将反馈发送到特定的电子邮件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托管的电子邮件服务中收到电子邮件。.请帮助我....
因为您没有串联$ userEmail。 替换为:
$Header .= 'From: Customer <$userEmail>' . "\\r\\n";
有了这个:
$Header .= "From: Customer <".$userEmail.">" . "\\r\\n";
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.