This question has been answered by BobRay. See the first response.
$modx->mail->set(modMail::MAIL_FROM_NAME, 'desiredFromName');
$modx->mail->set(modMail::MAIL_FROM_NAME, 'desiredFromName');
I don't think it depends on sendMail(). I couldn't find any references to sendMail() anywhere in any of the relevant classes.
FYI, many hosts have mail() turned off. You can use SMTP as an alternative by setting the SMTP System Settings in the Manager.
If you install QuickEmail and run it in debug mode, it might tell you a little about what's happening. You can also use QuickEmail as a wrapper to send your mail, though it's probably not necessary.
$this->modx->getService('mail', 'mail.modPHPMailer');
$this->modx->mail->set(modMail::MAIL_BODY, $msg);
$this->modx->mail->set(modMail::MAIL_FROM, $this->modx->getOption('emailsender'));
$this->modx->mail->set(modMail::MAIL_FROM_NAME, $this->modx->getOption('site_name'));
$this->modx->mail->set(modMail::MAIL_SENDER, $this->modx->getOption('emailsender'));
$this->modx->mail->set(modMail::MAIL_SUBJECT, $subject);
if (!empty($msgAlt)) { // plaintext version
$this->modx->mail->set(modMail::MAIL_BODY_TEXT, $msgAlt);
}
$this->modx->mail->address('to', $email, $name);
$this->modx->mail->address('reply-to', $this->modx->getOption('emailsender'));
$this->modx->mail->setHTML(true);
$sent = $this->modx->mail->send();
$this->modx->mail->reset();$this->_addlHeaders[] = "X-Remote-Host: " . $_SERVER['REMOTE_HOST'] . "\n";
if ($this->modx->getOption('reportRemoteHost',$this->spfconfig,true) && !empty($_SERVER['REMOTE_HOST'])) {
$this->_addlHeaders[] = "X-Remote-Host: " . $_SERVER['REMOTE_HOST'] . "\n";
}
if ($this->modx->getOption('reportRemoteAddr',$this->spfconfig,true)) {
if(!empty($_SERVER['REMOTE_ADDR'])) {
$this->_addlHeaders[] = "X-Remote-Address: " . $_SERVER['REMOTE_ADDR'] . "\n";
}
/* If the client is working through a proxy... */
if(!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) {
$this->_addlHeaders[] = "X-Http-X-Forwarded-For: " .
$_SERVER['HTTP_X_FORWARDED_FOR'] . "\n";
}
}
if ($this->modx->getOption('reportRemoteUser',$this->spfconfig,true) && !empty($_SERVER['REMOTE_USER'])) {
$this->_addlHeaders[] = "X-Remote-User: " . $_SERVER['REMOTE_USER'] . "\n";
}
foreach($this->_addlHeaders as $key => $value) {
/* MS-Win mail servers want crlf and *don't* want a trailing pair
* necessary only for addl headers */
if(PHP_OS == "WIN32" || PHP_OS == "WINNT") {
if (isset($value) && ! empty($value)) {
$this->_addlHeaders[$key] = preg_replace("/\n$/", "", $value);
$this->_addlHeaders[$key] = preg_replace("/\n/", "\r\n", $value);
}
}
$this->modx->mail->header($value);
}$headers = "Bcc:".$bcc."\r\n".
"MIME-Version: 1.0\r\n".
"X-Mailer: PHP/".phpversion();
$modx->getService("mail", "mail.modPHPMailer");
$modx->mail->set(modMail::MAIL_SENDER, $from);
$modx->mail->set(modMail::MAIL_FROM, $from);
$modx->mail->set(modMail::MAIL_FROM_NAME, $fromName);
$modx->mail->set(modMail::MAIL_SUBJECT, $subject);
$modx->mail->set(modMail::MAIL_BODY, $body);
$modx->mail->address("to", $to);
$modx->mail->address("reply-to", "[email protected]");
$modx->mail->header($headers);
$modx->mail->setHTML(true);$modx->getService("mail", "mail.modPHPMailer");
$modx->mail->set(modMail::MAIL_SENDER, $from);
$modx->mail->set(modMail::MAIL_FROM, $from);
$modx->mail->set(modMail::MAIL_FROM_NAME, $fromName);
$modx->mail->set(modMail::MAIL_SUBJECT, $subject);
$modx->mail->set(modMail::MAIL_BODY, $body);
$modx->mail->address("to", $to);
$modx->mail->address("reply-to", "[email protected]");
$modx->mail->address("bcc", $bcc);
$modx->mail->setHTML(true);$modx->mail->headers[] = 'desired header here';