PHPmailer with SMTP. Should send emails, but it doesn't. Neither upgrade the database. What should I change?
Posted on 2009-02-23
I've made this is difficuly = "Hard" because it can be. Even though it might be easy for you who knows how to send emails via SMTP from a php script. I, on the other hand, don't know how...
The file I run via a cron makes no error message, but it doesn't work. To me it seams like either the phpmailer class, og the phpmailer file doesn't get the correct info from the database, or some part is missing.
It is supposed to:
1) Run the sql to see if there are any emails in the database that has not yet been sent and that the time has come for it to be sent. (These are emaisl prewritten and put in the database with a time and date for sending. When the now-time is greater than the set time, the email should be sent.)
2) Send each email that needs to be sent (build it first and then send it)
3) Update the database to reflect that those emaisl have been sent.
The file is not made by me, and I figure I'm fooling around too much to understand the code. My friend (who is better than I in php coding, says he doesn't understand the "dialect") - May be you can help me...?
Putting in an echo "and my message here" I've seen that the sql runs correct. The file also "understands" that mail-type = 2 means that it should build an HTML email.
=> However the emails are not being sent, and I see that in the database it's not getting updated neither.
I know the SMTP host, username, password and other info in the database is correct. But I can't see if the PHPmailer class is able to find the info anywhere. I can't figure where it actually asks the database for that info...
When I send a broadcast email (email without delay) I see that the connection has error when I put in the wrong smtp host... But it doesn't give any error message ig I put in the wrong username or password...
IF I try to send emails from the same file through sendmail it updates the database, but the mails are never received by the "to adress".
I attach the code here. The first code is the entire file running the cron.