adonisjs / mail

AdonisJS Email Provider
MIT License
106 stars 34 forks source link

how can set email from with config #23

Closed plantir closed 6 years ago

plantir commented 6 years ago

I use Zoho smtp and must set from in email how can set from in the config this is my mail config

order: {
    driver: "smtp",
    service: "Zoho",
    host: "smtp.zoho.com",
    port: 465,
    secure: false,
    requireTLS: false,
    auth: {
      user: "orders@***.com",
      pass: **
    }
  },
 support: {
    driver: "smtp",
    service: "Zoho",
    host: "smtp.zoho.com",
    port: 465,
    secure: false,
    requireTLS: false,
    auth: {
      user: "support@***.com",
      pass: ***
    }
  }

and this my controller:

const user = await User.find(1);
    await Mail.connection("support").send(
      "emails.referal",
      { user: user.toJSON() },
      message => {
        message
          .to(user.email)
          .from("support@***.com")
          .subject("join cashineh now...");
      }
    );
    response.send("success");

I want to set messege.from() just one time in config is it possible?

RomainLanz commented 6 years ago

Hey @vrwebdesign! 👋

I don't know if it's currently available. Maybe @thetutlage will know better.

thetutlage commented 6 years ago

Isn’t it as simple as defining a value in config and use it using the config provider?

RomainLanz commented 6 years ago

I believe he want to set it up only once (in the config) and then it's used by default every time you send an email.