Concrete5 on Azurewebsites email setup problem - "Client does not have permissions to send as this sender"

Permalink
I have a website that I have recently created as an Azure website using the Concrete5 template on Azure. I am a first time user of Concrete5 and am really liking it. I have hit a snag with the email setup and am hoping to get some help.

I am using the External SMTP Server option under the SMTP Method section. I have tried entering the settings for my Office365 email account per below:
Mail server: smtp.office365.com
Username: email@domain.com
Password: mypassword
Encryption: TLS
Port: 587

I am getting the following error when sending the test email: "The following error was found while trying to send the test email: 5.7.60 SMTP; Client does not have permissions to send as this sender".

I have also tried with my gmail account:
Mail server: smtp.gmail.com
Username: email@gmail.com
Password: mypassword
Encryption: SSL
Port: 465

But then I get the following error: "The following error was found while trying to send the test email:
5.7.14 <https://accounts.google.com/ContinueSignIn?sarp=1&scc=1&plt=AKgnsbsjL
5.7.14 CAMa2rJ9sO_ofVUydl2waEb8oGuGHLKCfjgyLM-7-zzeS2JtahepPjmfgpMibzs3UG3f6G
5.7.14 _HseXB9rCl5Eb7yMSaF2Bzmxu5YNCrJdxspolhYueauytbtEcj50g0s3--Qf4S1fucrRmN
5.7.14 gkI9X5Et-EUDmPImD38674x-wW_rX5oIHvJNvbtrrE3TNRNM-hHszDY50y94JUjhZ2hIfS
5.7.14 TxgZAEjlW4otevyVG3GYpP5saYwI> Please log in via your web browser and
5.7.14 then try again.
5.7.14 Learn more at
5.7.14https://support.google.com/mail/answer/78754... a62sm23166730pfj.40 - gsmtp"

I am assuming these errors are occurring because the site is trying to send as a generic email address such as email@domain.com and Office365 will not allow that. I have seen several posts that talk about editing the app.php file to set the email from address and have tried setting the from email address by making the following update to application/config/app.php file:

<?php
define('EMAIL_DEFAULT_FROM_ADDRESS', 'do-not-reply@domain.com');
define('EMAIL_DEFAULT_FROM_NAME', 'OrgName Webmaster');
define('FORM_BLOCK_SENDER_EMAIL', EMAIL_DEFAULT_FROM_ADDRESS);
define('EMAIL_ADDRESS_FORGOT_PASSWORD', EMAIL_DEFAULT_FROM_ADDRESS);
return array(
);

Can anyone give me some direction here? I am really hoping to get email working throughout the site.

 
Steevb replied on at Permalink Reply
Steevb
Why use 'External SMTP', does email not work with the default 'PHP' settings?
michaelmowry replied on at Permalink Reply
No it does not work with the Default PHP Mail Function. The error is:

"The following error was found while trying to send the test email:
Unable to send mail: mail(): Failed to connect to mailserver at "localhost" port 25, verify your "SMTP" and "smtp_port" setting in php.ini or use ini_set()"
michaelmowry replied on at Permalink Reply
Any ideas on this? I'd like to get email working.
WebcentricLtd replied on at Permalink Best Answer Reply
hello

not sure if these apply to you but I've had the same problems with both gmail and office365.

When using office365 the username must be the name of the mailbox that you are using or it will not work - it gives the exact message you are receiving if it does not match.

With gmail you may have to unlock the account to use smtp with it. If you log into your gmail account and then in the same browser window go to google and search on 'gmail unlock captcha' and visit the first result you should be able to sort it from there.

What version of Concrete5 are you using by the way?
michaelmowry replied on at Permalink Reply
I couldn't get Office365 to work but that change "Allowing less secure apps to access your account" in gmail got that working for me. Thanks a lot for the suggestion!
WebcentricLtd replied on at Permalink Reply
are you using concrete5.6 or 5.7?
michaelmowry replied on at Permalink Reply
5.7