public function PHPMailer::Send in SMTP Authentication Support 7.2
Same name and namespace in other branches
- 5 smtp.module \PHPMailer::Send()
- 7 smtp.phpmailer.inc \PHPMailer::Send()
Creates message and assigns Mailer. If the message is not sent successfully then it returns FALSE. Use the ErrorInfo variable to view description of the error.
Return value
bool
File
- ./
smtp.phpmailer.inc, line 560 - The mail handler class in smtp module, based on code of the phpmailer library, customized and relicensed to GPLv2.
Class
- PHPMailer
- PHPMailer - PHP email transport class NOTE: Requires PHP version 5 or later @package PHPMailer @author Andy Prevost @author Marcus Bointon @copyright 2004 - 2009 Andy Prevost
Code
public function Send() {
try {
if (count($this->to) + count($this->cc) + count($this->bcc) < 1) {
throw new phpmailerException(t('You must provide at least one recipient email address.'), self::STOP_CRITICAL);
}
// Set whether the message is multipart/alternative
if (!empty($this->AltBody)) {
$this->ContentType = 'multipart/alternative';
}
$this->error_count = 0;
// reset errors
$this
->SetMessageType();
$header = $this
->CreateHeader();
$body = $this
->CreateBody();
if (empty($this->Body)) {
throw new phpmailerException(t('Message body empty'), self::STOP_CRITICAL);
}
// digitally sign with DKIM if enabled
if ($this->DKIM_domain && $this->DKIM_private) {
$header_dkim = $this
->DKIM_Add($header, $this->Subject, $body);
$header = str_replace("\r\n", "\n", $header_dkim) . $header;
}
// Choose the mailer and send through it
switch ($this->Mailer) {
case 'smtp':
return $this
->SmtpSend($header, $body);
default:
return $this
->MailSend($header, $body);
}
} catch (phpmailerException $e) {
$this
->SetError($e
->getMessage());
if ($this->exceptions) {
throw $e;
}
if ($this->logging) {
watchdog_exception('smtp', $e);
}
return FALSE;
}
}