файл administrator/components/com_virtuemart/classes/ps_main.php
function vmCreateMail( $from='', $fromname='', $subject='', $body='' ) { global $mosConfig_absolute_path, $mosConfig_sendmail; global $mosConfig_smtpauth, $mosConfig_smtpuser; global $mosConfig_smtppass, $mosConfig_smtphost; global $mosConfig_mailfrom, $mosConfig_fromname, $mosConfig_mailer; $phpmailer_classname='phpmailer'; if( file_exists( $mosConfig_absolute_path . '/libraries/phpmailer/phpmailer.php') ) { $phpmailer_path = $mosConfig_absolute_path . '/libraries/phpmailer/phpmailer.php'; }elseif( file_exists( $mosConfig_absolute_path . '/includes/phpmailer/class.phpmailer.php')) { $phpmailer_path = $mosConfig_absolute_path . '/includes/phpmailer/class.phpmailer.php'; $phpmailer_classname = 'mosphpmailer'; } require_once( $phpmailer_path ); if( class_exists( $phpmailer_classname )) { $mail = new $phpmailer_classname(); } $phpmailer_path = dirname( $phpmailer_path ); $mail->PluginDir = $phpmailer_path .'/'; $mail->SetLanguage( 'en', $phpmailer_path . '/language/' ); $mail->CharSet = vmGetCharset(); $mail->IsMail(); $mail->From = $from ? $from : $mosConfig_mailfrom; $mail->FromName = $fromname ? $fromname : $mosConfig_fromname; $mail->Sender = $from ? $from : $mosConfig_mailfrom; $mail->Mailer = $mosConfig_mailer; // Add smtp values if needed if ( $mosConfig_mailer == 'smtp' ) { $mail->SMTPAuth = $mosConfig_smtpauth; $mail->Username = $mosConfig_smtpuser; $mail->Password = $mosConfig_smtppass; $mail->Host = $mosConfig_smtphost; } else // Set sendmail path if ( $mosConfig_mailer == 'sendmail' ) { if (isset($mosConfig_sendmail)) $mail->Sendmail = $mosConfig_sendmail; } // if if( $subject ) { $mail->Subject = vmAbstractLanguage::safe_utf8_encode( $subject, $mail->CharSet ); } if( $body) { $mail->Body = $body; } // Patch to get correct Line Endings switch( substr( strtoupper( PHP_OS ), 0, 3 ) ) { case "WIN": $mail->LE = "\r\n"; break; case "MAC": // Mac OS9 $mail->LE = "\r"; break; case "DAR": // Mac OSX default: // change nothing break; } return $mail; }
почту через sendmail на php отправить очень просто:
if(!@$mail = popen($sendmail, ‘w’)) {
$this->SetError(‘popen failed: ‘. $this->Lang(‘execute’) . $this->Sendmail . ‘ ‘ . $sendmail);
return false;
}
fputs($mail, $header);
fputs($mail, $body);
$result = pclose($mail);
Комментарий by Василий — 29 января 2011 @ 22:10