An open API service indexing awesome lists of open source software.

https://github.com/damir-sijakovic/sendmails

Two functions that send mail with html message and attachment.
https://github.com/damir-sijakovic/sendmails

attachment html mail php sendmail

Last synced: about 2 months ago
JSON representation

Two functions that send mail with html message and attachment.

Awesome Lists containing this project

README

          

# Send mail functions

Two functions to send mail with html message and attachment.

## sendHtmlMail($to, $from, $subject, $html, &$msg=null)

Arguments:

* to - destination email address
* from - sender email address
* subject - email subject
* html - message in html format (can be plain text)
* msg - optional arg that pass error message

Return:

Boolean, error messages are passed through msg reference argument.

## sendAttachment($to, $from, $subject, $html, $filename, $filepath, &$emsg=null)

* to - destination email address
* from - sender email address
* subject - email subject
* html - message in html format (can be plain text)
* msg - optional arg that pass error message
* filename - file name of attachment in email
* filepath - path to file you want to send
* emsg - optional arg that pass error message

Return:

Boolean, error messages are passed through emsg reference argument.

Example:

$msg = '';
$html = '

Hello


This is paragraph.

';
$sendOk = sendAttachment('destination@fake.fake', 'from@fake.fake', 'hello subject', $html, 'somefile2.pdf', __DIR__ . '/somefile2.pdf', $msg);
if (!sendOk)
{
die($msg);
}

## Issues
Attachments don't work on my webhosts email but do work on gmail.
Sometimes it takes few minutes for mail to appear.

### Have Fun
`Developed and tested under 5.4.118-1-manjaro/xfce/docker/portainer`