phpemailtwiliosendgridsendgrid-api-v3

Is there a way to add profile pics in e-mails sent from code


So, what I am doing is I am using Sendgdrid's API (PHP API Library) to send e-mails. The sending part works, I just want to overhaul it a little to add some more customization, but I am not sure if it's possible. I am using CodeIgniter so I am skipping some code, but you get the general idea.

What I want to achieve is to customize this part

Example of what I want to modify

I want the company logo to appear there instead of the automatically generated A.

I want to achieve this:

enter image description here

Is there some header I need to modify?

My mail sending process is this (fictional data):

$email = new \SendGrid\Mail\Mail(); 
$email->setFrom("noreply@mail.com", "Sender Name");
$email->setSubject("Mail Subject");
$email->addTo($mail_data->email, $mail_data->name);
$email->addContent(
    "text/html", $this->load->view('mails/recovery', $mail_data, TRUE)
);

$sendgrid = new \SendGrid($this->config->item('sendgrid_api_key'));

try {
    $response = $sendgrid->send($email);
    // do some stuff
} catch (Exception $e) {
    // do some other stuff
}

So the mail arrives correct and everything, but is there a way to add like an avatar for the mail sender? Like the company's logo or something. Is there a way to do this via code?

I checked something about creating a google account, but what if I am using a noreply@ address and also what happens if for another mail I use a different address? I'd have to add google accounts to each one?


Solution

  • So, based on Matthew Setter's comment on my question, I researched a little bit and the solution to this is the BIMI DNS record. BIMI stands for Brand Indicators for Message Identification

    It requires the following:

    1. You need an SVG version of your icon/logo/pic and the max weight of the image must be 32kb. The image must be publicly accessible, so it must be something like https://www.yourdomain.com/images/icon.svg

    2. You need a BIMI Certificate, that's the tricky part, because they are currently extremely expensive, Digicert sells them as Verified Mark Certificate and they cost $1,499.00 USD per year, so it won't do for most people. You also need to host the certificate also on your domain on a public link, something like https://www.yourdomain.com/cert/bimi.pem

    3. You need to have a defined DMARC policy, if you don't have one it might show warnings/errors.

    4. You need to add a TXT record with the following structure

      1. The name of the record is: default._bimi

      2. v (version) BIMI1: v=BIMI1;

      3. l (location) of the SVG image: https://www.yourdomain.com/images/icon.svg

      4. a (address I think) of your certificate: https://www.yourdomain.com/cert/bimi.pem

    So the end result is something like this:

    TXT default._bimi "v=BIMI1;l=https://www.yourdomain.com/images/icon.svg;a=https://www.yourdomain.com/cert/bimi.pem" 3600
    

    I hope the certificate authorities reduce the price of this as it can be useful for many businesses but $1,499.00 for a certificate is way too much for the regular business owner.

    OTHER RESOURCES

    You can also use these tools to generate/validate BIMI records.