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
Related
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.
I am using Mail Queue to send emails in my application (https://pear.php.net/package/Mail_Queue/)
The same code works fine on windows (php version: 5.5.28) and it gives the below mentioned exception on unix (php version 5.6)
PHP User Notice 'yii\base\ErrorException' with message 'Error in sending mail: authentication failure [SMTP: STARTTLS failed (code: 220, response: Begin TLS negotiation now)]'
The mail server credentials are fine. They are same on linux as well as on windows. Code 220 means the server is ready (via http://www.serversmtp.com/en/smtp-error)
I read somewhere it is due to php5.6 and it will work fine on 5.5 but I don't think so that would be a valid answer/solution to the problem.
I guess this is because PHP 5.6 does SSL peer verification by default and PHP 5.5 doesn't. I guess if you fix a valid SSL certificate it should work, or disable ssl verify-peer in your code.
Without knowledge of Mail_Queue I don't know how to fix it without any example code.
Sending emails from EC2 instances is limited by Amazon and strictly throttled at network level. This is to prevent spamming and other abuses.
If you have a large amount of emails to send to your customers, the recommended way is to use Amazon Simple Email Service. With Amazon SES, you can send transactional email, marketing messages, or any other type of high-quality content and you only pay for what you use.
Connecting to the Amazon SES SMTP Endpoint
If you really need to send emails from an EC2 instance, you must use an Elastic IP Adress and ask Amazon's support to remove limitations on SMTP traffic from that EIP.
Alternatively I will suggest you can use Sendgrid, they are fast and accurate, provides 12000 emails per month for free as well.
I am using a php based website in my company for question and answers so I had set the smtp details to send and receive mails to users, now my company moved to Exchange server for emails.After that my php application is not able to send any emails to the users inside my company.
I tried with the new exchange server settings and luckily one mail got send but when again I tried later no success.
Please guide me if any thing else I need to set. Or SMTP wont work for exchange server?
Thanks,
Ashok Kumar.
There are a numbers of things that might make Exchange deny access.
Firstly, check TLS Authentication
I've had luck using http://phpmailer.worxware.com/
As a last resort you can create a receive connector with only basic auth on the exchange server set to receive emails only from your PHP servers IP address. I recommend doing this using a local IP over a VPN. You will need to edit the existing receive connectors so their listening IP range does not include the IP address used on the new receive connectors.
I'm trying to send emails with CodeIgniter using smtp.googlemail.com. No problems with code but Google is preventing me from sending that email - here's the email I received on my Google account:
A third party recently tried to use an application to connect to your
Google account.
We blocked the connection attempt in case it would be a hacker trying
to access your account.
If you have not made this connection attempt, it may mean a third
party is trying to access your account. We recommend that you log into
your account and reset your password immediately. We blocked the
connection attempt in case it would be a hacker trying to access your
account.
If this is your account and if you are having trouble to get there,
follow the troubleshooting procedure explained at
http://support.google.com/mail?p=client_login.
I have followed the link and didn't find a solution.
I have the same issue, got an email from Google saying "Sign-in attempt prevented" when I was trying the same. I am ignoring what you have received from google and the text of email. Finally I solved the issue to send mail using CodeIgniter Email library today.
To use Google SMTP in CodeIgniter you need to make 2 (two) changes into Gmail account setting: (N.B. Please be aware that it is now easier for an attacker to break into your account -says Google)
Set off 2-step Verification.
Allow less secure apps: ON (or Enable)
Now use 'smtp_host' as ssl://smtp.gmail.com instead of smtp.googlemail.com
Hope this help.
I have a PHP page that uses PEAR Mail to send a message through a Google Apps mail account. The page is only active in the fall and winter, and it was working great when it was last used in January.
Now, as I prep the site for the fall, this page no longer works. I have the exact same problem as described at SMTP Error 535 (Incorrect authentication data) using PEAR mail There have been no answers to that question and it won't allow me to comment, so I'm starting a new question.
I am using code identical to that posted by pavan kumar at Send email using the GMail SMTP server from a PHP page .
The error message is:
authentication failure [SMTP: Invalid response code received from server (code: 535, response: Incorrect authentication data)]
I double-checked that the login for the mail user had not been changed since January. I copied and pasted the address and password from my script into the Gmail login in my browser. It worked, so I know my parameters are correct. This account is a business domain address, not #gmail.com.
I am trying to connect at:
$host = "ssl://smtp.gmail.com";
$port = "465";
I also tried specifying tls:// and port 587, no luck. I also set the host to "googlemail.com" instead of "gmail.com" per a suggestion in another SO thread.
I did a var_dump() of the $smtp object, and confirmed my address and password were passed into it successfully and accurately.
The account is on a cPanel system that recently upgraded to PHP 5.3.5 and Apache 2.2.22. It seems unlikely that change could have triggered this problem, but I mention it in case it could be a factor.
Edit: Found http://support.google.com/a/bin/answer.py?hl=en&answer=176600 which says "...you must configure an SPF record for your domain with the IP address of the device or application to ensure that recipients do not reject mail sent from it. You must also add this IP address to the Email Whitelist box in your Google Apps control panel. For example. if your sending device sends from 123.45.67.89, add that address to your SPF record without removing the Google Apps mail servers from the record..." Unfortunately I don't have an Email Whitelist box in this domain - it's the free <10 user account which evidently doesn't have that feature.
Edit 2:
Related: http://support.google.com/mail/bin/answer.py?hl=en&answer=78775
Edit 3:
I set up the account in Opera mail, and sent successfully using both AUTH LOGIN and AUTH PLAIN settings.
The problem was located at my web host, not Google's mail server.
The account is on a cPanel server, and the admin had set it so that only designated user accounts could access external SMTP servers. He disabled that requirement in order for me to test, and my mail system immediately started working.
So far, though, I have found no documentation on how to log into cPanel as one of the authorized users when its SMTP Authentication is activated. I will update this if I find some.