Configure SMTP with Office365 account

Get help from other users here.

Moderators: Developer, Contributor

Post Reply
GoodFeel
Posts: 8
Joined: 18 Jun 2019, 10:35

Configure SMTP with Office365 account

Post by GoodFeel »

Hello,

I try to set up the SMTP configuration on my Mantis tenant.

I don't found a lot information about this topic but I configured like this :

Code: Select all

$g_enable_email_notification = ON; #enables the email messages
$g_phpMailer_method = PHPMAILER_METHOD_SMTP;
$g_smtp_host 		= 'smtp.office365.com';
$g_smtp_connection_mode = 'tls';
$g_smtp_port 		= 587;
$g_smtp_username 	= 'youremail@yourdomain.com'; #replace with your email address used to log into Office 365
$g_smtp_password 	= '********'; #replace with your email password
$g_from_email		= 'youremail@yourdomain.com'; # Office 365 requires this to match the username email address
$g_return_path_email    = 'youremail@yourdomain.com'; # Office 365 requires this to match the username email address
After that, I try to create a bug to send a mail notification but it doesn't work. I check the mantis logs :

Code: Select all

2020-01-20 11:15 CET MAIL email_api.php:1410 email_send() ERROR: Message could not be sent - SMTP Error: data not accepted.SMTP server error: DATA END command failed Detail: STOREDRV.Submission.Exception:SendAsDeniedException.MapiExceptionSendAsDenied; Failed to process message due to a permanent exception with message Cannot submit message. 0.35250:0A00AB80, 1.36674:0A000000, 1.61250:00000000, 1.45378:02000000, 1.44866:3A280000, 1.36674:0E000000, 1.61250:00000000, 1.45378:3F280000, 1.44866:6C020000, 16.55847:6B120000, 17.43559:0000000004020000000000000000000000000000, 20.52176:140F548A1A00101043050000, 20.50032:140F548A8A17000000000000, 0.35180:48050000, 255.23226:0A00 SMTP code: 554 Additional SMTP info: 5.2.0
I don't found any official document about this configuration, only some topics on forums.

Can you please help me ?

Thanks a lot.
GoodFeel
Posts: 8
Joined: 18 Jun 2019, 10:35

Re: Configure SMTP with Office365 account

Post by GoodFeel »

Nobody try to set up an O365 SMTP ?

Thanks.
GoodFeel
Posts: 8
Joined: 18 Jun 2019, 10:35

Re: Configure SMTP with Office365 account

Post by GoodFeel »

Finally, it's works with this syntax :

Code: Select all

$g_phpMailer_method = PHPMAILER_METHOD_SMTP;
$g_smtp_host = 'smtp.office365.com';
$g_smtp_connection_mode = 'tls';
$g_smtp_port = '587';
$g_smtp_username = 'xxxx@domain';
$g_smtp_password = "password";
$g_return_path_email   = 'xxxx@domain';
$g_administrator_email='xxxx@domain';
$g_webmaster_email=$g_administrator_email;
$g_from_email='xxxx@domain';
Thanks.
mushu
Posts: 344
Joined: 04 Jan 2017, 17:41

Re: Configure SMTP with Office365 account

Post by mushu »

Thank you for posting the solution. We are going to be moving to O365 soon and this will help me configure our Mantis also.
adriano.ferreira
Posts: 1
Joined: 07 Sep 2021, 19:37

Re: Configure SMTP with Office365 account

Post by adriano.ferreira »

Hello everyone.
I´m trying to use Mantis with Office365 account without success.
I installed xampp with mantis, edited the C:\xampp\htdocs\mantis\config_inc.php and add these lines:

$g_allow_signup = ON; //allows the users to sign up for a new account
$g_enable_email_notification = ON; //enables the email messages
$g_phpMailer_method = PHPMAILER_METHOD_SMTP;
$g_smtp_host = 'smtp.office365.com';
$g_smtp_connection_mode = 'tls';
$g_smtp_port = 587;
$g_smtp_username = '123@456.com'; //replace it with your O365 address
$g_smtp_password = '12345678'; //replace it with your O365 password
$g_administrator_email = 'outofcovid@example.com'; //this will be your administrator email address

No matter what i do it doesn´t work, if i change to gmail it works fine but i changed the permissions in gmail in order to accept insecure apps.
What i´m doing wrong, should i add somekind of permission in O365 pannel?
rabbit
Posts: 12
Joined: 12 Jun 2021, 06:32

Re: Configure SMTP with Office365 account

Post by rabbit »

Hi.

I used the code above and it worked fine for a while.
Then, after resetting the password twice for a user it suddenly stopped.
I receive the error in mantislog:
CET MAIL email_api.php:1432 email_send() EROR: Message could not be sent - SMTP Error: data not accepted.

Furthermore the email not sent now starting to add up in the queue and therefore making everything really slow.

Any idea?
Are there any blocking mechanism at @outlook.com (Which is my email-adress I'm sending from).

EDIT:
After trying to send a few emails with the error above, it suddenly returns:
CET MAIL email_api.php:1251 email_send_all() Server not responding for 5 seconds, aborting

This sound for me like the office365 is rejecting and blocking several requests in a short time????
mushu
Posts: 344
Joined: 04 Jan 2017, 17:41

Re: Configure SMTP with Office365 account

Post by mushu »

Aliya77
Posts: 1
Joined: 18 May 2023, 17:40

Re: Configure SMTP with Office365 account

Post by Aliya77 »

Hi guys
Having trouble configuring SMTP with my Office365 account. Followed the instructions, but encountering issues with sending emails. Need assistance in properly setting up the SMTP connection to ensure seamless email communication through Office365. Any guidance or troubleshooting tips would be greatly appreciated.Free Fire
elftron
Posts: 5
Joined: 14 Feb 2017, 05:36

Re: Configure SMTP with Office365 account

Post by elftron »

When I set this up on our server the key was that the $g_from_email had to be exactly the same as $g_smtp_username.
By doing this however the $g_from_name is ignored and the emails are sent out as the office 365 description on our account instead of $g_from_name

So I just changed the description on the service account I use.
Post Reply