Source of file SMTPEmail.php
Size: 3,430 Bytes - Last Modified: 2022-01-13T10:01:14+00:00
/var/www/docs.ssmods.com/process/src/code/SMTPEmail.php
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115 | <?php class SMTPEmail extends Email { /** * makes ReplyTo work like BCC etc * @return [type] [description] */ public function getReplyTo() { $h = $this->customHeaders; return !empty($h['Reply-To']) ? $h['Reply-To'] : null; } /** * makes ReplyTo work like BCC etc * @param [type] $val [description] */ public function setReplyTo($val) { $this->addCustomHeader('Reply-To', $val); return $this; } /** * proxy method for file attachments * @param [type] $filename [description] * @param [type] $attachedFilename [description] * @param [type] $mimetype [description] * @return [type] [description] */ public function attachFile($filename, $attachedFilename = null, $mimetype = null) { // generate a name for the file if we aren't supplied one if (!$attachedFilename) $attachedFilename = trim(str_replace(Director::baseFolder(), '', $filename), '/'); // Get the full path if (!file_exists($filename)) $filename = Director::getAbsFile($filename); // try to attach the file if (file_exists($filename)) { $this->attachFileFromString(file_get_contents($filename), $attachedFilename, $mimetype); } // throw else { throw new Exception("Could not attach '$filename' to email. File does not exist."); } return $this; } public function Absolute($link) { return Director::protocolAndHost() . str_replace('//','/', '/' . $link); } /** * this is mainly a test harness * @return [type] [description] */ public function setupMailer() { Requirements::clear(); $this->parseVariables(true); if(empty($this->from)) $this->from = Email::config()->admin_email; $headers = $this->customHeaders; if(project()) $headers['X-SilverStripeSite'] = project(); $to = $this->to; $from = $this->from; $subject = $this->subject; if ($sendAllTo = $this->config()->send_all_emails_to) { $subject .= " [addressed to $to"; $to = $sendAllTo; if($this->cc) $subject .= ", cc to $this->cc"; if($this->bcc) $subject .= ", bcc to $this->bcc"; $subject .= ']'; unset($headers['Cc']); unset($headers['Bcc']); } else { if($this->cc) $headers['Cc'] = $this->cc; if($this->bcc) $headers['Bcc'] = $this->bcc; } if ($ccAllTo = $this->config()->cc_all_emails_to) { if(!empty($headers['Cc']) && trim($headers['Cc'])) { $headers['Cc'] .= ', ' . $ccAllTo; } else { $headers['Cc'] = $ccAllTo; } } if ($bccAllTo = $this->config()->bcc_all_emails_to) { if(!empty($headers['Bcc']) && trim($headers['Bcc'])) { $headers['Bcc'] .= ', ' . $bccAllTo; } else { $headers['Bcc'] = $bccAllTo; } } if ($sendAllfrom = $this->config()->send_all_emails_from) { if($from) $subject .= " [from $from]"; $from = $sendAllfrom; } Requirements::restore(); return self::mailer()->setupMailer($to, $from, $subject, $this->attachments, $headers); } } |