PHP imap_open inconsistent - php

I have a very strange imap_open issue I haven't been able to figure out.
I've got two servers, both running PHP5 with imap and open ssl installed and everything enabled. Let's call them SERVER A and SERVER B.
I've got two gmail accounts, EMAIL1#GMAIL.COM and EMAIL2#GMAIL.COM.
I've got a PHP script using imap_open to access these accounts at imap.gmail.com over SSL (port 993).
SERVER A: Can access both gmail accounts using the script. No account level authentication procedure was needed, so nothing like disabling Gmail's two step authentication, for example, was needed.
SERVER B: Can only access email1#gmail.com using the script, email2#gmail.com gives the following errors:
Retrying PLAIN authentication after [ALERT] Please log in via your web
browser: https://support.google.com/mail/acco
Can not authenticate to IMAP server: [ALERT] Please log in via your
web browser: https://support.google.com/mail/acco
Any idea of what could be going on here? Nothing special in the PHP logs...

This issue was due to the server being blocked as a "suspicious device" by Gmail. Go to your recent activities (as opposed to devices) and start from there to enable access to the device (which in this case was being blocked by IP address). Then disable the CAPTCHA challenge. Note this last step took some hours to go through, and did not work immediately.

Related

what properties should be set for my SMTP

I have setup a Website based on HTML with the exception of a contact.php page. I am hosting this website on my Rasberry Pi 3 computer on Debian flavor of linux Jesse Light. This is headless as it hosts my Portfolio website. I am using Apache2 webserver and installed sendmail as my Mail Transfer Agent (MTA). The problem is I have been spinning my wheels researching for the past week and I am stuck.
My issue is I send email from my php contact page on my live server but nothing ever arrives in my inbox after sending it. I get a mail sent message from my php script after about a minute after sending but then Nothing arrives in the inbox. I am thinking My SMTP on my php.ini is not correct. I put my website domain name FQ name. I am using Microsoft Exchange Online hosted email domain by GoDaddy. Also, anyone have any good advise on what my from / to should be set to on my SMTP configurations?
Sounds like a direct reject to me.
Some hints:
check the SMTP logs from your MS Exchange server (if a connection has been opened and potentially been refused for whatever reason)
check the PHP / Apache logs and see, whether an PHP fatal error or warning occured (mybad bad credentials or wrong port?)
I have had bad experiences with MS Exchange server and SMTP, make sure its proper setup.
check the credentials and settings from an independent client to see if they work flawless.
Hope that helps. Otherwise please provide more details and log samples.
Is your contact.php program hosted on the Godaddy server? If yes- It's not possible to send mail through Godaddy shared hosting servers using your own SMTP settings. You can only send from Godaddy's relay server when using a shared hosting plan. If you wanted to be able to send through your own SMTP servers, you'd need to be hosting with either a VPS or Dedicated Server plan.
Check maillog on your server and you will get the smtp connection timeout errors.
Let me know, in case the problem is something different- will try to address it.

server send emails using gmail smtp gets alerts

I did something like this to make my web app sends mails through gmail's SMTP. I tried locally and it worked. after I upload to the server (which is in another country) I get this error:
authentication failure [SMTP: Invalid response code received from server (code: 534, response: 5.7.9 Please log in with your web browser and then try again. Learn more at 5.7.9 https://support.google.com/mail/bin/answer.py?answer=78754 5.7.9 {WEBLOGINREQUIRED} fl2sm1579003pab.23 - gsmtp)]
is there a way to ignore this?
For anyone still interest the answer:
Google have to allow your app to use your own account, to allow this google provided an easy way, just go to https://accounts.google.com/DisplayUnlockCaptcha, then click continue, then with 10 min, use your application to try to send email again, and google will remember the application/service and allow your application to access your account as long as you don't change your password.
cheers

Need Configuration Settings

I have developed flex based application with php. My client is using Windows 2003 Server. I installed IIS Server and Php Installer into my client machine. I configured php into IIS Server and its working fine.
Query:
I wrote a mail code for sending mail to my application user. My client is using internal mail server. I want to send a mail through my application. I used smtp.gmail.com into my application and Its working perfectly. But when I am using client internal mail server. It is showing below mentioned error.
"Failed to set sender [SMTP: Invalid response code received from server. (Code: 554, response: Mail from mail-id rejected for policy reasons.]"
Please help me out to solve this query. Thanks in advance.
Well, why not to ask client's system administrator about "policy reasons"?
This should be no PHP problem but rather a problem with the SMTP server or a misconfiguration of the SMTP settings in your application. SMTP servers can be equipped with a lot of security features (I think that's what they mean with policy reasons) to allow or deny sending emails through that server from specific hosts, from specific uses, with specific authentication mechanisms, to specific domains, to specific users, etc. (list can be continued endlessly). Contact the responsible system administrator for that SMTP server and ask him what settings you need to feed into your SMTP mailer in your application.

Sending mail in PHP using Exchange SMTP

I have a client that uses Exchange (although I'm not sure which version). From what I know, they do have an SMTP for their Exchange however supposedly I cannot use it since my system is on PHP+Linux. It will not work for the Exchange being on Windows licensed server. How true is it? I am trying to send the mail through SMTP and not directly to the Exchange server.
They did give the details on the SMTP and I have tried and yes, it doesn't work. I got an error 'Could not connect to SMTP host'.
What are my other options in sending mail through PHP? Been googling around and found something called WebDav. Would that be a wise choice?
EDIT>
I guess something went right overnight however it's not everything. I can (presumably) connect to the SMTP however I can't send email to other domains. I tried sending to it's own domain and it works. Checked my inbox and the email is there however if I send to Live or GMail, it doesn't work. It gives me this error:
PHPMAILER_RECIPIENTS_FAILEDemail#email.com
The email#email.com is a correct existing email. I have even tested with GMail and there's no problem in sending. Now what I would like to know is where the problem lies. Could it really be in the coding or the SMTP server?
As an extra note, I'm using Joomla 1.5.22.
They are incorrect. SMTP is a standardized protocol and has nothing to do with the operating system used from a client. Exchange has a few particular things that are somewhat odd about how it handles SMTP but they will more than likely not matetr for you.
If you're getting a 'Could not connect to SMTP host', that's a pretty fundamental issue it means one of several things:
The server is not accepting inbound SMTP from anyone
The server is not accepting inbound SMTP from your IP
There is a firewall getting in the way.
There are a lot of ways to troubleshoot this. The easiest, assuming this is a server that should be accessible to the general internet, is to, from a command prompt, run 'telnet 1.2.3.4 25' (where 1.2.3.4 is the IP where the server should be). If that connects, then see if you can run the same command from the machine where your PHP is. If not, tell the client that you can't seem to access SMTP from the outside and see if they can troubleshoot.
You could use gmail? I know you might not be using phpmailer, but the how-to should set you in the right direction.
It sounds like "they" (who I'm guessing are the sys-admin for the network you're on?) may have other ideas on you doing this though - ports could be restricted etc.

PHPMailer, fsockopen(), possible Apache issue?

I'm using PHPMailer to send out site contacts.
In development, the script works perfectly with the GMail service over smtp. However, in production, inside the client's DMZ, it appears unable to connect to the SMTP service they have there. I have connected to the same service using telnet to port 25, so I know for sure it exists and is available to the server.
Are there any circumstances where php might not be able to open a socket connection (fsockopen)...? The php extension openssl is loaded and ok.
The error is "Unable to connect to SMTP service".
Thanks!
If the same code works elsewhere on the same OS/webserver/PHP, then its nothing to do with the PHP code. Indeed you say:
inside the client's DMZ, it appears unable to connect to the SMTP service
This rather suggests that its a configuration issue on the production network. If you can get shell access to the srver, try telneting to port 25 on the SMTP server - I'll bet it doesn't work.
If there's a long delay in getting back this error message then it might be a DNS issue rather than a firewall/routing issue.
C.
This was resolved, turned out to be an authentication issue. Hooray for finally being able to talk to the network administrators!

Categories