Phpmailer using own domain - email

how i can use my email like example#domain.ph in phpmailer. because i always have an error even i have a correct credentials.
2020-05-14 09:21:24 SERVER -> CLIENT: 220 smtp.gmail.com ESMTP e13sm1851788pfh.19 - gsmtp
2020-05-14 09:21:24 CLIENT -> SERVER: EHLO localhost
2020-05-14 09:21:24 SERVER -> CLIENT: 250-smtp.gmail.com at your service, [114.108.210.106]250-SIZE 35882577250-8BITMIME250-AUTH LOGIN PLAIN XOAUTH2 PLAIN-CLIENTTOKEN OAUTHBEARER XOAUTH250-ENHANCEDSTATUSCODES250-PIPELINING250-CHUNKING250 SMTPUTF8
2020-05-14 09:21:25 CLIENT -> SERVER: AUTH LOGIN
2020-05-14 09:21:25 SERVER -> CLIENT: 334 VXNlcm5hbWU6
2020-05-14 09:21:25 CLIENT -> SERVER: [credentials hidden]
2020-05-14 09:21:25 SERVER -> CLIENT: 334 UGFzc3dvcmQ6
2020-05-14 09:21:25 CLIENT -> SERVER: [credentials hidden]
2020-05-14 09:21:25 SERVER -> CLIENT: 535-5.7.8 Username and Password not accepted. Learn more at535 5.7.8 https://support.google.com/mail/?p=BadCredentials e13sm1851788pfh.19 - gsmtp
2020-05-14 09:21:25 SMTP ERROR: Password command failed: 535-5.7.8 Username and Password not accepted. Learn more at535 5.7.8 https://support.google.com/mail/?p=BadCredentials e13sm1851788pfh.19 - gsmtp
SMTP Error: Could not authenticate.
2020-05-14 09:21:25 CLIENT -> SERVER: QUIT
2020-05-14 09:21:25 SERVER -> CLIENT: 221 2.0.0 closing connection e13sm1851788pfh.19 - gsmtp
SMTP Error: Could not authenticate.
this is my configuration:
$mail->isSMTP();
$mail->Host = 'smtp.gmail.com';
$mail->SMTPAuth = true;
$mail->SMTPAutoTLS = true;
$mail->Username = 'example#domain.ph';
$mail->Password = '';
$mail->SMTPSecure = PHPMailer::ENCRYPTION_STARTTLS;
$mail->Port = 587;

As per the logs that I have read you need to turn your Less Secure Account On. Follow this steps below.
Help CenterCommunity
Setting up video conferencing for remote work? Set up Meet to help your team work remotely.
Control access to less secure apps
This article is for administrators. For actions users can take, go to Less secure apps & your Google Account.
You can block sign-in attempts from some apps or devices that are less secure. Apps that are less secure don't use modern security standards, such as OAuth. Using apps and devices that don’t use modern security standards increases the risk of accounts being compromised. Blocking these apps and devices helps keep your users and data safe.
Examples of apps that don’t support modern security standards include:
​Native mail, contacts, and calendar sync applications on older versions of iOS and OSX​
​Some computer mail clients, such as older versions of Microsoft Outlook
Examples of apps that do support modern security standards are Gmail, Windows Mail, Office 365, Outlook for Mac, Instagram, PayPal, Amazon, Facebook, and Basecamp.
Transitioning to more secure app access to Google Accounts
Less secure apps can make it easier for hijackers to break into user accounts and devices. Blocking sign-ins from these apps helps keep accounts safe. For these reasons, Google is limiting password-based programmatic sign-ins to Google Accounts.
If you don't allow sign-ins from less secure apps
If you allow sign-ins from less secure apps
Notice of setting removal
Use alternatives to less secure apps
Manage access to less secure apps
You can allow users to turn on or off access by less secure apps or disable their ability to allow less secure apps.
Sign in to your Google Admin console.
Sign in using your administrator account (does not end in #gmail.com).
Go to the settings for Less secure apps:
From the Admin console Home page, go to Securityand thenLess secure apps.
To see Security on the Home page, you might have to click More controls at the bottom.
OR, if the "Less secure apps" option isn't visible:
From the Admin console Home page, go to Securityand thenBasic settings.
Then, under Less secure apps, click Go to settings for less secure apps.
Select the setting for less secure apps:
Disable access to less secure apps (Recommended)
Users can’t turn on access to less secure apps.
When you disable access to less secure apps while a less secure app has an open connection with a user account, the app will time out when it tries to refresh the connection. Timeout periods vary per app.
Allow users to manage their access to less secure apps
Users can turn on or turn off access to less secure apps.

Related

How to send e-mail from a custom e-mail made on Cloudflare?

I made a custom e-mail address on Cloudflare, and have tried adding it to Gmail as a sender address following this tutorial, but I get stuck on the SMTP Server, Username, Password section when I get the following authentication error:
Authentication failed. Please check your username/password.
Server returned error: "535-5.7.8 Username and Password not accepted. Learn more at 535 5.7.8 https://support.google.com/mail/?p=BadCredentials d18-20020a170906305200b00730799724c3sm240511ejd.149 - gsmtp , code: 535"
I have tried with Port 465 and SSL and Port 587 and TLS.
This answer solved it.
To generate an App Password you can do this:
Go to your Google Account.
Select Security.
Under "Signing in to Google," select App Passwords. You may need to sign in. If you don’t have this option, it might be because:
a. 2-Step Verification is not set up for your account.
b. 2-Step Verification is only set up for security keys.
c. Your account is through work, school, or other organization.
d. You turned on Advanced Protection.
At the bottom, choose Select app and choose the app you using and then Select device and choose the device you’re using and then Generate.
The steps were copied from here.

How to connect to Microsoft Exchange Smtp?

Usually, for Gmail and outlook we have app passwords to connect to SMTP (though we can use email passwords by enabling less secure app access).
But for my Microsoft Exchange mail I can't find the app password, nor I can connect my app with the mail to send emails.
import smtplib
password = "mypassword"
email = "usrname#tsac-uae.com"
s = smtplib.SMTP('smtp.office365.com', 587)
s.starttls()
s.login(email, password)
I get an error saying
smtplib.SMTPAuthenticationError: (535, b'5.7.139 Authentication unsuccessful,
SmtpClientAuthentication is disabled for the Tenant.
Visit https://aka.ms/smtp_auth_disabled for more information.
[AM9P192CA0015.EURP192.PROD.OUTLOOK.COM]')
To avoid these complications, I need to use an app password. But I can't find how to set up app password in exchange. Also, the steps said in the website is outdated. I can't find enable SMTP anywhere.
You need to enable SMTP submission (an organization-wide setting)
within your Microsoft Tenant as per the link you get in the error message, which expands to https://learn.microsoft.com/en-us/exchange/clients-and-mobile-in-exchange-online/authenticated-client-smtp-submission.
The change can only be performed via powershell. An easy way to perform this change is by logging in at https://shell.azure.com. To use Exchange Online cmdlets in the Azure Cloud Shell, the Exchange Online cmdlets need to be imported using Connect-EXOPSSession.
Once connected, to enable SMTP submission use
Set-TransportConfig -SmtpClientAuthenticationDisabled $false
Make sure you read the article linked above to understand the security implications.
Also beware that
If your authentication policy disables basic authentication for SMTP,
clients cannot use the SMTP AUTH protocol even if you enable the
settings outlined in this article. For more information, see Disable
Basic authentication in Exchange Online.

Jenkins SMTP Configuration - 535 Authentication Failed

I'm trying to configure Jenkins email notification via Mailer plugin 1.21.
I'm using secureserver.net as a mailing server.
I have a problem with "SMTP Authentication", the "Test configuration" is reporting 535 Authentication:
Failed to send out e-mail
javax.mail.AuthenticationFailedException: 535 Authentication Failed
for jenkins#xxxx.com
at
com.sun.mail.smtp.SMTPTransport$Authenticator.authenticate(SMTPTransport.java:809)
at
com.sun.mail.smtp.SMTPTransport.authenticate(SMTPTransport.java:752)
at
com.sun.mail.smtp.SMTPTransport.protocolConnect(SMTPTransport.java:669)
at javax.mail.Service.connect(Service.java:317) at
javax.mail.Service.connect(Service.java:176) at
javax.mail.Service.connect(Service.java:125) at
javax.mail.Transport.send0(Transport.java:194) at
javax.mail.Transport.send(Transport.java:124)
My settings are as follows:
SMTP server: smtpout.secureserver.net
Use SMTP Authentication: yes
User Name: jenkins#xxxx.com
Password: ******
Use SSL - yes
SMTP Port - 465
Charset - UTF-8
I'm using the same credentials to connect via webmail: https://email11.secureserver.net/webmail.php. I don't have a connection problem.
Do you have any explanation why jenkins refuse to authenticate?
As google doesn't allow login from less secure apps you have do the following steps:
1. Login to "https://myaccount.google.com/security"
2. Enable "Allow less secure apps" to "ON"
Then check the "Test configuration" in jenkins.
From https://products.secureserver.net/email/email_outlook.htm:
NOTE: "smtpout.secureserver.net" is an SMTP relay server. In order to
use this server to send e-mails, you must first activate SMTP relay on
your e-mail account. Log on to your Manage Email Accounts page to set
up SMTP relay.
Did you do this?
I solved similar issue by creating a new SMTP credential from AWS SES.
But I am still amazed why old credentials didn't work with jenkins even if it was working with other applications.

raspberry pi gmail sign in blocked by google

I want to send automated emails form my raspberry pi. I followed this guide https://wiki.archlinux.org/index.php/SSMTP
I got an error when trying to send an email
~>cat tmp.txt | mail -s "subject" -t EXAMPLE#gmail.com
mail: cannot send message: Process exited with a non-zero status
I also got an email from Google telling me a sign-in attempt was prevented because I wasn't using modern security standards:
Should I be using a different was of sending email or should I use a different email service?
You can go to that gmail account setting and look for "Allow less secure apps" and turn it on.
myaccount.google.com -> "Sign-in & security" -> "Allow less secure apps: ON"
That will allow you to send email with less secure login process.
Otherwise, I saw some post which said this helped on python 2.7
Ref: https://www.raspberrypi.org/forums/viewtopic.php?t=94023&p=659005
Enable Less Secure Apps doesn't help for me.
However I found that if I turn on 2-factor auth and set a app-specific password then I can successfully log in to my gmail account.

SwiftMailer not send mail with Google App account

I'm using Symfony and I'm trying to send an email with swiftmailer. I have an account set up with google app (produccion#mydomain.com) and when I try to send shows me the following error:
Failed to authenticate on SMTP server with username
"produccion#mydomain.com" using 2 possible authenticators
I tried it with my personal gmail account and send the message correctly with the same settings. Just change the username and password.
# Swiftmailer Configuration
swiftmailer:
transport: smtp
host: smtp.gmail.com
username: produccion#mydomain.com #email#gmail.com
password: google_app_password #gmail_password
auth_mode: login
port: 587
encryption: tls
I've been searching the internet and I've found this page from Google, where I can change the access to less secure applications.
https://www.google.com/settings/security/lesssecureapps
In my gmail account this option is active, but if I turn shows me the same error when sending email.
I've been trying to change this setting in google app account but it tells me that this option is not available for google app.
Any idea to send emails from this account by google app? I have to set something else?
EDIT
It seems Gmail prefers OAuth, Swiftmailer supports this authentication mech but its not really documented.
https://developers.google.com/gmail/xoauth2_protocol
https://github.com/swiftmailer/swiftmailer/blob/5.x/lib/classes/Swift/Transport/Esmtp/Auth/XOAuth2Authenticator.php
Any idea how I use it in Symfony?
Have you tried setting the transport parameter to gmail as mentioned in the cookbook? http://symfony.com/doc/current/cookbook/email/gmail.html
# Swiftmailer Configuration
swiftmailer:
transport: gmail
username: your_gmail_username
password: your_gmail_password