Send email with profile picture PHP mail function

 ̄綄美尐妖づ 提交于 2020-06-24 14:46:08

问题


I would like to show a profile picture in my users inbox when they receive an email sent from my website with PHP.

In this image the first email is from my website and the second one is what I want.

And here is my PHP mail function:

            $emailTo=$_POST['emialNewPass'];
            $emailSubject="Recovery";
            $emailLoctuz="noreply@loctuz.com";
            $message="msg";

            $headers  = 'MIME-Version: 1.0' . "\r\n";
            $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
                            // En-têtes additionnels
            $headers .= 'To: '.$emailTo."\r\n";
            $headers .= 'From: Loctuz Security <'. $emailLoctuz . '>' ."\r\n";

            if(@mail($emailTo,$emailSubject,$message, $headers))
            {
                ?><script>window.location = "?sent";</script><?php                  
            }

回答1:


After research and testing I found:

  1. There is no "programmatic" way to affect the profile picture.
  2. The best way to apply a profile picture to Gmail recipients' inboxes is to create a Google+ account for the sending address and add a profile picture to it (more below)
  3. Other email services and inboxes (including Airmail, Sparrow, Postbox, and Thunderbird) use Gravatar (more below)
  4. I'm sure there are email services not touched by this...

Use Google+ to add profile pics to Gmail:

  1. Go to http://plus.google.com/
  2. If you are already logged in, log out
  3. Click "Use another account"
  4. Click "More options" -> "Create account"
  5. Enter first and last name
  6. Under Choose your username click "I prefer to use my current email address"
  7. Enter the email address you want to send from with a profile picture to the "Your email address" field
  8. Fill out the rest of the fields
  9. Once your account is created, click your profile in the top right, and click "Change: where your profile picture should be. Upload a profile picture
  10. Now wait for a day or two! It took almost 24 hours for my new Google+ profile picture to propagate to emails in my Gmail inbox. During this waiting period, I also deleted (and went to Trash->Delete forever) all emails from the address, and also removed it from my Gmail Contacts.
  11. After a day or so, I was able to send an email to myself from the address in question and see the profile picture I uploaded to Google+ in my Gmail inbox :)

Use Gravatar to add profile pics to other inboxes:

  1. Go to http://gravatar.com/
  2. Click Sign In and sign in if you are not already
  3. Add an email address - use the email address to want to send form with a profile picture
  4. Upload an image



回答2:


I don't believe that there is a way to add an avatar image to a MIME email

As far as Gmail goes. If you add an image to your Gmail profile, it will automatically be shown when another Gmail user gets an email from you, looks you up in their address book, or chats with you.

Assuming its not gmail then its read from the users address book or contacts. Neither of which you have access to edit.




回答3:


I believe what you try to accomplish has nothing to do with PHP for mail sending, but rather code for displaying your website favicon. Here is a good read about them: https://css-tricks.com/favicon-quiz/



来源:https://stackoverflow.com/questions/43091844/send-email-with-profile-picture-php-mail-function

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!