|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #48826 Add attachment support to mail()
Submitted: 2009-07-07 04:30 UTC Modified: 2018-03-13 21:45 UTC
Avg. Score:1.0 ± 0.0
Reproduced:0 of 1 (0.0%)
From: php at richardneill dot org Assigned:
Status: Suspended Package: Mail related
PHP Version: * OS: *
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
From: php at richardneill dot org
New email:
PHP Version: OS:


 [2009-07-07 04:30 UTC] php at richardneill dot org
It would be a really nice if mail() supported an extra parameter for 
attachments. Perhaps an array containing the filenames (and whose 
keys, if present, would be the name of the attachments).

(I know there are ways of doing this by installing pear classes, but 
that isn't always an option. And it's awkward to do it by hand).

Given that mail() is already rather overloaded, it might be worth 
adding another function, say mail_attach() to do it.

Reproduce code:
Current alternative:

$cmd = "echo '$BODY_TEXT'  | mutt -s '$SUBJECT' -a '$filename_1' -a '$filename_2' '$email'";
exec ($cmd);

which is ugly, has external dependencies, only works on Linux, and will break in interesting ways if shell-quoting isn't corrected.


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2011-01-01 16:13 UTC]
-Summary: wish: mail() to support attachments +Summary: Add attachment support to mail() -Package: Feature/Change Request +Package: Mail related -Operating System: Linux +Operating System: * -PHP Version: 6CVS-2009-07-07 (CVS) +PHP Version: *
 [2011-03-17 18:10 UTC] anrdaemon at freemail dot ru
"Given the fact it is already overloaded", it is better to cleanup and shape the code for a more robust and predictable functionality.
Not to bloat it unnecessarily.
 [2018-03-13 21:45 UTC]
-Status: Open +Status: Suspended
 [2018-03-13 21:45 UTC]
In my opinion, adding explicit multipart support to mail() is not
desirable, since there are already several existing userland
solutions.  So this feature request is controversial, and as such
would require the RFC process[1].  Anybody is welcome to start it!
For the time being, I'm suspending this ticket.

[1] <>
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Mon Feb 26 12:01:26 2024 UTC