desirable-objects / grails-sendgrid

Sendgrid plugin for Grails
10 stars 11 forks source link

The sendMail {} method is not found in a controller #4

Open veggie2u opened 11 years ago

veggie2u commented 11 years ago

I have successfully sent an email from a controller with the sendGridService.sendMail {} method, and using the builder. (That works great, so thanks!) However, just calling sendMail {} from a controller method give me an error.

There is a no such method error for MyController.sendMail() is applicable for argument types MyController$_display_closure1. It appears that the sendMail method isn't registered in the controller, or is not expecting a closure?

antony commented 11 years ago

Hi there,

Hmm. The controller sendMail method was added for allowing easy porting from the mail plugin to the sendgrid plugin, although I've never officially supported it (I think sending mail from controllers is bad practice)

If you raise an issue I will take a look at getting this working again.

Cheers, Antony On 10 Jun 2013 04:42, "Chris Ward" notifications@github.com wrote:

I have successfully sent an email from a controller with the sendGridService.sendMail {} method, and using the builder. (That works great, so thanks!) However, just calling sendMail {} from a controller method give me an error.

There is a no such method error for MyController.sendMail() is applicable for argument types MyController$_display_closure1. It appears that the sendMail method isn't registered in the controller, or is not expecting a closure?

— Reply to this email directly or view it on GitHubhttps://github.com/aiten/grails-sendgrid/issues/4 .

veggie2u commented 11 years ago

I would agree with you about sending email from controllers, but I was hoping that others did anyway. I am hoping to use a couple of plugins that send emails for things like signups, and password recovery and such. I was hoping that if the sendgrid sendMail method worked in the controllers, that the other plugins would use the controller method instead of the mailService service. Hmmm... I wonder... have you tried essentially aliasing the mailService service with your sendGridService by creating your service as a spring bean with the mailService name? I might have to try that... but I am a little green to grails still.

What would be nice actually would be an api that grails supports that sendMail or your plug in implement, so that any plugin wanting to send email would use that api and everything would just work :-)

antony commented 11 years ago

What would be nice actually would be an api that grails supports that sendMail or your plug in implement, so that any plugin wanting to send email would use that api and everything would just work :-)

Oddly enough Peter Ledbrook and I started working on this, and we got a basic structure working. Sadly, I don't have time to continue this work at the moment so I've had to leave it for now.