PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Wednesday, August 31, 2022

[FIXED] How to Create RFC Mail Format with Attachment?

 August 31, 2022     pear, php     No comments   

Issue

I have a problem with creating an RFC mail format with attachment. Please help me! Thanks


Solution

Attachments are made in multipart email format. You better use some lib to do it. But if you want to manage it yourself you need to create a document separated by multipart bounaries, that contains files in base64 encoding:

First, email headers:

To: admin@example.com
Subject: hi, admin!
Content-Type: multipart/alternative; boundary="some_random_string"

Than body:

This is a multi-part message in MIME format.
some_random_string
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: 8bit
<p>Email text and image</p>
<img src="cid:attached_image">

some_random_string
Content-Type: image/png;name="some.png"
Content-Transfer-Encoding: base64
Content-ID: <attached_image> //<- this used in CID
Content-Disposition: inline; filename="some.png"
//here goes base64 encoded image.

There are some example function in php.net. Look here in comments.



Answered By - Oroboros102
Answer Checked By - Timothy Miller (PHPFixing Admin)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing