|
noalyss
Version-6.7.2
|
Description of class_sendmail. More...
Public Member Functions | |
| add_file (FileToSend $file) | |
| Add file to the message. | |
| compose () | |
| create the message before sending | |
| mailto ($p_mailto) | |
| set the recipient | |
| send () | |
| Send the message. | |
| set_from ($p_from) | |
| set the from $p_from has the form name <info@phpcompta.eu> | |
| set_message ($p_message) | |
| body of the message (utf8) | |
| set_subject ($p_subject) | |
| verify () | |
| verify that the message is ready to go | |
Private Attributes | |
| $afile | |
| $content | |
| $from | |
| $mailto | |
| $message | |
| $subject | |
Description of class_sendmail.
Definition at line 29 of file class_sendmail.php.
| Sendmail::add_file | ( | FileToSend $ | file | ) |
Add file to the message.
| FileToSend | $file | file to add to the message |
Definition at line 79 of file class_sendmail.php.
References $file.
{
$this->afile[] = $file;
}
create the message before sending
Definition at line 103 of file class_sendmail.php.
References $content, $file, $uid, content, from, and verify().
{
$this->verify();
$uid = md5(uniqid(time()));
// a random hash will be necessary to send mixed content
$separator = md5(time());
// carriage return type (we use a PHP end of line constant)
$eol = PHP_EOL;
// main header (multipart mandatory)
$headers = "From: " . $this->from . $eol;
$headers .= "MIME-Version: 1.0" . $eol;
$headers .= "Content-Type: multipart/mixed; boundary=\"" . $separator . "\"" . $eol . $eol;
$headers .= "Content-Transfer-Encoding: 7bit" . $eol;
$headers .= "This is a MIME encoded message." . $eol . $eol;
$headers .= $eol . $eol;
// message
$headers .= "--" . $separator . $eol;
$headers .= "Content-Type: text/plain; charset=\"utf-8\"" . $eol;
$headers .= "Content-Transfer-Encoding: 7bit" . $eol . $eol;
$headers .= $this->message . $eol . $eol;
// attachment
for ($i = 0; $i < count($this->afile); $i++)
{
$file = $this->afile[$i];
$file_size = filesize($file->full_name);
$handle = fopen($file->full_name, "r");
$content = fread($handle, $file_size);
fclose($handle);
$content = chunk_split(base64_encode($content));
$headers .= "--" . $separator . $eol;
$headers .= "Content-Type: " . $file->type . "; name=\"" . $file->filename . "\"" . $eol;
$headers .= "Content-Disposition: attachment; filename=\"" . $file->filename . "\"" . $eol;
$headers .= "Content-Transfer-Encoding: base64" . $eol;
$headers.=$eol;
$headers .= $content . $eol . $eol;
}
$headers .= "--" . $separator . "--";
$this->content = $headers;
}
| Sendmail::mailto | ( | $ | p_mailto | ) |
set the recipient
| type | $p_mailto | has the form name <email@email.com> |
Definition at line 61 of file class_sendmail.php.
Referenced by send().
{
$this->mailto = $p_mailto;
}
| Sendmail::send | ( | ) |
| Sendmail::set_from | ( | $ | p_from | ) |
set the from $p_from has the form name <info@phpcompta.eu>
Definition at line 43 of file class_sendmail.php.
References from.
{
$this->from = $p_from;
}
| Sendmail::set_message | ( | $ | p_message | ) |
body of the message (utf8)
| type | $p_message |
Definition at line 70 of file class_sendmail.php.
{
$this->message = $p_message;
}
| Sendmail::set_subject | ( | $ | p_subject | ) |
| $p_subject | set the subject |
Definition at line 52 of file class_sendmail.php.
{
$this->subject = $p_subject;
}
| Sendmail::verify | ( | ) |
Sendmail::$afile [private] |
Definition at line 33 of file class_sendmail.php.
Sendmail::$content [private] |
Definition at line 37 of file class_sendmail.php.
Referenced by compose().
Sendmail::$from [private] |
Definition at line 36 of file class_sendmail.php.
Sendmail::$mailto [private] |
Definition at line 32 of file class_sendmail.php.
Sendmail::$message [private] |
Definition at line 35 of file class_sendmail.php.
Sendmail::$subject [private] |
Definition at line 34 of file class_sendmail.php.