public function PHPMailer::SetFrom in SMTP Authentication Support 7
Same name and namespace in other branches
- 7.2 smtp.phpmailer.inc \PHPMailer::SetFrom()
Set the From and FromName properties
Parameters
string $address:
string $name:
Return value
boolean
File
- ./
smtp.phpmailer.inc, line 505 - 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 SetFrom($address, $name = '', $auto = 1) {
$address = trim($address);
$name = trim(preg_replace('/[\\r\\n]+/', '', $name));
//Strip breaks and trim
if (!self::ValidateAddress($address)) {
$this
->SetError(t('Invalid address') . ': ' . $address);
if ($this->exceptions) {
throw new phpmailerException(t('Invalid address') . ': ' . $address);
}
if ($this->logging) {
watchdog('smtp', 'Invalid address: %address', array(
'%address' => $address,
), WATCHDOG_ERROR);
}
return FALSE;
}
$this->From = $address;
$this->FromName = $name;
if ($auto) {
if (empty($this->ReplyTo)) {
$this
->AddAnAddress('ReplyTo', $address, $name);
}
if (empty($this->Sender)) {
$this->Sender = $address;
}
}
return TRUE;
}