问题
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:
- There is no "programmatic" way to affect the profile picture.
- 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)
- Other email services and inboxes (including Airmail, Sparrow, Postbox, and Thunderbird) use Gravatar (more below)
- I'm sure there are email services not touched by this...
Use Google+ to add profile pics to Gmail:
- Go to http://plus.google.com/
- If you are already logged in, log out
- Click "Use another account"
- Click "More options" -> "Create account"
- Enter first and last name
- Under Choose your username click "I prefer to use my current email address"
- Enter the email address you want to send from with a profile picture to the "Your email address" field
- Fill out the rest of the fields
- 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
- 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.
- 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:
- Go to http://gravatar.com/
- Click Sign In and sign in if you are not already
- Add an email address - use the email address to want to send form with a profile picture
- 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