Has anyone had any success with using a free SMTP server like smtp.gmail.com or smtp.live.com to send email in Dynamics AX?
I have a normal (not business) gmail account that I enter into the email parameters form. I use smtp.gmail.com and tried ports 587 and 465. I’ve tried with and without NTLM. We've also tried Hotmail and outlook email accounts.
We have tried this in AX 4 and AX 2012. We run a job like the ones below; the job runs, gives no error, but no email is sent. We've checked spam folders and tried different addresses as receivers. We've pinged the smtp servers and that works from the aos server and client.
My guess is that it does not work because there is no option to enable TLS, which both the live and gmail servers require. Is there a way to overcome this?
Are we missing anything obvious? Has anyone every used a gmail/Live smtp to send email from AX?
-----------------------------------------------------------------------------------------------------------------------
I don't think the problem is with the code, but I'll add it anyway. We've tried a number of ways to send email via X++, here are two of the main ones:
SysMailer mailer = new SysMailer(); SysEmailParameters parameters = SysEmailParameters::find(); ; if (parameters.SMTPRelayServerName) { mailer.SMTPRelayServer(parameters.SMTPRelayServerName, parameters.SMTPPortNumber, parameters.SMTPUserName, SysEmailParameters::password(), parameters.NTLM); } else { mailer.SMTPRelayServer(parameters.SMTPServerIPAddress, parameters.SMTPPortNumber, parameters.SMTPUserName, SysEmailParameters::password(), parameters.NTLM); } mailer.fromAddress("someoneElse@gmail.com"); mailer.tos().appendAddress("someone@gmail.com"); mailer.body("Hallo"); mailer.sendMail();
We have also tried System.Net.Mail:
System.Net.Mail.MailMessage mailMessage; System.Net.Mail.SmtpClient smtpClient; System.Net.Mail.MailAddress mailFrom; System.Net.Mail.MailAddress mailTo; str smtpServer; ; mailFrom = new System.Net.Mail.MailAddress('sender@contoso.com',"Sender name"); mailTo = new System.Net.Mail.MailAddress('recipient@contoso.com',"Recipient name"); smtpServer = SysEmaiLParameters::find(false).SMTPRelayServerName; mailMessage = new System.Net.Mail.MailMessage(mailFrom,mailTo); mailmessage.set_Subject('This is email subject'); mailmessage.set_Body('This is email body'); smtpClient = new System.Net.Mail.SmtpClient(smtpServer); smtpClient.Send(mailmessage); mailMessage.Dispose();
*This post is locked for comments