-1

I am trying to send an email with a profile picture using PHPMailer !

Specifically I mean adding a profile picture to the email (not sending an image or file).

profile picture

Is it possible to add this feature to the code below:

https://github.com/PHPMailer/PHPMailer#user-content-a-simple-example

I searched the resources and didn't find anything, has anyone who has worked with PHP Miller been able to do this, in any way ?

<?php
//Import PHPMailer classes into the global namespace
//These must be at the top of your script, not inside a function
use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\SMTP;
use PHPMailer\PHPMailer\Exception;

//Load Composer's autoloader (created by composer, not included with PHPMailer)
require 'vendor/autoload.php';

//Create an instance; passing `true` enables exceptions
$mail = new PHPMailer(true);

//Server settings
$mail->SMTPDebug = SMTP::DEBUG_SERVER;                      //Enable verbose debug output
$mail->isSMTP();                                            //Send using SMTP
$mail->Host       = 'smtp.example.com';                     //Set the SMTP server to send through
$mail->SMTPAuth   = true;                                   //Enable SMTP authentication
$mail->Username   = '[email protected]';                     //SMTP username
$mail->Password   = 'secret';                               //SMTP password
$mail->SMTPSecure = PHPMailer::ENCRYPTION_SMTPS;            //Enable implicit TLS encryption
$mail->Port       = 465;                                    //TCP port to connect to; use 587 if you have set `SMTPSecure = PHPMailer::ENCRYPTION_STARTTLS`

//Recipients
$mail->setFrom('[email protected]', 'Mailer');
$mail->addAddress('[email protected]', 'Joe User');     //Add a recipient
$mail->addAddress('[email protected]');               //Name is optional
$mail->addReplyTo('[email protected]', 'Information');
$mail->addCC('[email protected]');
$mail->addBCC('[email protected]');

//Attachments
$mail->addAttachment('/var/tmp/file.tar.gz');         //Add attachments
$mail->addAttachment('/tmp/image.jpg', 'new.jpg');    //Optional name

//Content
$mail->isHTML(true);                                  //Set email format to HTML
$mail->Subject = 'Here is the subject';
$mail->Body    = 'This is the HTML message body <b>in bold!</b>';
$mail->AltBody = 'This is the body in plain text for non-HTML mail clients';

$mail->send();
echo 'Message has been sent';

Has anyone been able to do this (is it possible) ?

6
  • 1
    to choose your profile picture in gmail, look here : support.google.com/mail/answer/35529 Commented Aug 3 at 7:04
  • Agree with the answer below, this is not part of the general email specification. Some email providers give you the ability to add a picture, but most recipients will not see it if they don't use the same email provider as you. e.g. if I send an email from Gmail to Outlook, the Outlook recipient won't see my Gmail profile pic - and vice-versa. There may be some exceptions to this e.g. if providers have data-sharing arrangements outside of the standard email protocol. Commented Aug 3 at 7:43
  • @masoudiofficial As I said, the formal specification for sending emails does not include anything about specifying profile pictures. Therefore some companies have decided to add this feature for themselves - usually it is actually connected to your broader account with that provider (e.g. Google account or Microsoft account) rather than just an email inbox...the email client is merely one place where the picture might be shown, if the email is from you. It might also show if you comment on a youtube video or post on google reviews, for example. It's actually totally unrelated to email. Commented Aug 3 at 10:08
  • As YourCommonSense said below, if you're using an email provider which doesn't have this feature, you could use a service like Gravatar as an add-on, to tie your email address to an image hosted by them. Then it may show up in the inboxes of others when you send to them, if that is supported by the email client and service provider they are using. But there is no centrally agreed-upon standard for this for all services to implement, so the results you get will be inconsistent. Commented Aug 3 at 10:13
  • 1
    Check the first link I included - you can set BIMI up for any domain, but your logo/image will only show up in providers which support BIMI - eg GMail. The SO logo in the screenshot you include in your question is almost certainly a result of SO setting up BIMI. Commented Aug 5 at 10:29

1 Answer 1

2

As far as I can tell, it is not possible. "Profile image" is not a part of SMTP protocol, so you cannot just add it to email, similar to adding a subject.

Therefore, one doesn't "send" a profile picture. It just being added in the profile settings of the mail service that provided the email address. Then this image gets bound to this particular email address. Since then, all users of this service will be shown this picture next to emails from this address. And probably other services too, since this information being shared between services somehow.

Therefore, if your email service is gmail or MSN (or anything else that lets you to add a profile picture) then do so. Otherwise consider using Gravatar, which will bind a email address and an image, and then it will share this information with other email services.

Sign up to request clarification or add additional context in comments.

1 Comment

May I suggest you to read my answer entirely, including the part beyond the sentence you were looking for.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.