adonisjs / mail

AdonisJS Email Provider
MIT License
106 stars 34 forks source link

How use AdonisJS Mail with Mailgun driver? #17

Closed pirmax closed 6 years ago

pirmax commented 7 years ago

Hi,

How use AdonisJS Mail with Mailgun driver?

My code:

mailgun: {
        driver: 'mailgun',
        apiKey: Env.get('MAILGUN_API_KEY'),
        extras: {}
    }

The mail doesn't sended...

thetutlage commented 7 years ago

Impossible for me to tell why

You didn’t shared any code on how you send the email

What’s the output of mail.send method? Are there any exceptions?

pirmax commented 7 years ago

I have no console.log() when I execute this function...

const user = await User.find(1)

    const result = await Mail.send('emails.confirmation', user.toJSON(), (message) => {
        message
            .to(user.email)
            .from('Website <noreply@domain.com>')
            .subject('Please, confirm your Domain account!')
    })

    console.log(result)
thetutlage commented 7 years ago

Are there any exceptions being thrown or the program just hangs?

RezaHaidari commented 6 years ago

@thetutlage

await Mail.send('welcome',{}, (message) => {
      message
        .to('reza.haidari@gmail.com')
        .from('test@gmail.com')
        .subject('welcome')
    })

error :

SyntaxError: Unexpected token M in JSON at position 0 at JSON.parse () at Request.basicAuth.headers.post.then (C:\Users\Mortina\Desktop\iptv-panel\node_modules\@adonisjs\mail\src\Mail\Drivers\Mailgun.js:161:32) at at process._tickCallback (internal/process/next_tick.js:188:7)

update: worked for me.

dehypnosis commented 6 years ago

changed MAILGUN_DOMAIN=https://api.mailgun.net/v3/my.domain to MAILGUN_DOMAIN=my.domain

and works.

LeCoupa commented 4 years ago

Here is a quick tutorial to set up Adonis with Mailgun.

https://madsobel.com/blog/setting-up-mailgun-with-adonis.js/