Skip to content
Advertisement

Getting error response while sending email from ionic using PHPMailer

I am trying to create a reset password page in ionic where the user enter his email ,to reset the password of his account on my application. The thing is that I want to send a response from php telling the user if the email was sent to his email or not depending on values sent from php to ionic. The thing that is happening is that the email is sent but it is showing me a response error.

Here is my typescript code:

JavaScript

The php code:

JavaScript

Here is the error that I am getting:

JavaScript

I am using print json_encode(“”) to send response from php to ionic, it’s working everywhere except this one.

Advertisement

Answer

Here’s your problem:

JavaScript

PHPMailer’s debug output is not JSON compatible, so turn it off:

JavaScript

You an of course turn it into JSON by injecting your own debug output callback, but I doubt that’s what you want to do.

When debugging things like this, always look at the actual response you’re getting from the server in your browser dev tools – if you had looked at that you would have seen the PHPMailer debug output in the responses.

User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement