Kannan.P
Kannan.P

Reputation: 1273

this.smtpServersettings is sending mail to undelivered options instead of gmail

I want to send a email to real gmail ID's to the end users. So I used smtp.gmail.com as mail server with my own email user name & password. But if I use this.smtpServersettings in my application.cfc it's not sending a email. All the mail's are went to undelivered options. My sample code, App.cfc :

<cfset this.name='mailfn8'>
<cfset this.smtpServersettings={server:"smtp.gmail.com",username:"[email protected]",password:"mypassword"}>

My.cfm :

<cfmail from='[email protected]' to='[email protected]' subject='test' type='html' port="587" usetls="true">
    I'm seding a email by using this.smtpServersettings options.
</cfmail>

But the credentials are working great in below scenario,

-- If I set my details in application scope and use that values in cfmail tag
-- Directly set it in coldfusion mail server setting

For example, App.cfc :

<cfset this.name='mailfn8'>
<cffunction name='onApplicationStart'>

    <cfset application.server='smtp.gmail.com'>
    <cfset application.username='[email protected]'>
    <cfset application.password='mypassword'>

</cffunction>

My.cfm :

<cfmail from='[email protected]' to='[email protected]' server= '#application.server#' username='#application.userName#' password='#application.password#' subject='test' type='html' port="587" usetls="true">
    I'm seding a email by using application scope.
</cfmail>

The above working fine. So why this.smtpServersettings is send email to undelivered option instead of gmail. ? .Do I need to enable any other setting if I use this.smtpServerSetting ? Please help me on this. Correct me if I'm understood anything wrong. Thank you !.

Upvotes: 3

Views: 288

Answers (1)

Dan Roberts
Dan Roberts

Reputation: 4694

The smtpServerSettings struct does not support port and usetls.

https://tracker.adobe.com/#/view/CF-4204467

My suggestion is to create your own struct in application scope then pass to cfmail tag with argumentCollection attribute.

Upvotes: 3

Related Questions