I have a little problem with an iOS cordova Webapp and PHP. The code below works perfectly on the computer(Xampp):
<?php
require 'lib/sendMail.php';
require '../php/PHPMailerAutoload.php';
$mail = new PHPMailer;
$sendMail = new sendMail();
$mail->isSMTP();
$mail->Host = 'smtp.gmail.com';
$mail->SMTPAuth = true;
$mail->Username = 'ex@ex.de';
$mail->Password = 'expw';
$mail->SMTPSecure = 'tls';
$mail->Port = 587;
$mail->From = 'ex@ex.com';
$mail->FromName = 'Mailer';
$mail->addAddress($_POST['termin']['cityemail']);
$mail->isHTML(true);
$mail->Subject = 'ex';
$mail->Body = $sendMail->getMessage($_POST);
$mail->AltBody = $sendMail->getMessage($_POST);
if(!$mail->send()) {
print 'Message could not be sent.';
print 'Mailer Error: ' . $mail->ErrorInfo;
} else {
print 'Message has been sent';
}
?>
Note: I am using PhpMailer to send mails via the phone.
The problem is, that the phone is going crazy. Everything after "->" is ignored or something. This is how the screen looks after submitting the form:
How can this happen? The email is sending successfully on the browser.
The device is iPhone 5S 16GB with iOS 8.1.
Okay I've got a working solution. Simply put your php files on a server, make an ajax call with type = " post " and there you go. Example code below(I'm using jQuery validation plugin) :
$("#Formular").validate({
submitHandler: function(form) {
var dataString = $(form).serialize();
$.ajax(
{
url : 'http://yoururl.de/file.php',
type: "POST",
data : dataString,
success:function(data, textStatus, jqXHR)
{
$('body').html(data);
}
});
},
rules: {
'phone': {
required: false,
phoneDE: true
}
},
messages: {
'phone': {
required: "Bitte gültige Telefonnummer eingeben"
}
}
});
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.