简体   繁体   English

SMTP电子邮件未在iPhone cordova WebApp上发送,是否在浏览器中工作?

[英]SMTP Email is not sending on iPhone cordova WebApp, working in browser?

I have a little problem with an iOS cordova Webapp and PHP. 我对iOS cordova Webapp和PHP有点问题。 The code below works perfectly on the computer(Xampp): 下面的代码在计算机(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. 注意:我正在使用PhpMailer通过电话发送邮件。

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: 提交表单后,屏幕显示如下: iPhone屏幕

How can this happen? 怎么会这样 The email is sending successfully on the browser. 电子邮件已在浏览器上成功发送。

The device is iPhone 5S 16GB with iOS 8.1. 设备为带iOS 8.1的iPhone 5S 16GB。

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. 只需将您的php文件放到服务器上,用type =“ post”进行ajax调用即可。 Example code below(I'm using jQuery validation plugin) : 下面的示例代码(我正在使用jQuery验证插件):

$("#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"
            }
        }
    });

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM