I am running CB 1.2 Joomla 1.5.15 and was having trouble getting SMTP mail to work in CB. All would work fine if I had Joomla global configuration set to php mail function or sendmail, but nothing if I used smtp settings. I wanted to have it all go through a gmail account and had joomla configured as such.
All other joomla functions such as contact forms worked great.
I took a look at the code in ../administrator/components/comprofiler/comprofiler.class.php and the functions for sending mail were a mess.
I decided to rewrite it to use the built in joomla functions for this and all works great now no matter which mail setting joomla is using (php mail, sendmail, or smtp).
Here is the code I used:
comprofiler.class.php starting at line 50
replace the entire function & comprofilerCreateMail with this:
[code:1]
function & comprofilerCreateMail( $from = '', $fromname = '', $subject, $body ) {
global $_CB_framework;
$mail = JFactory::getMailer();
if($from == '')
{
$_CB_framework->getCfg( 'mailfrom' );
}
if($fromname == '')
{
$_CB_framework->getCfg( 'fromname' );
}
$mail->setSender( array( $from, $fromname ) );
$mail->setSubject( $subject );
$mail->setBody( $body );
return $mail;
}
[/code:1]
I also had to change the way the replyto is configured in the function comprofilerMail to work properly. This function follows directly after function & comprofilerCreateMail. I will post the whole function here to be sure you can replace with the necessary code:
[code:1]
function comprofilerMail( $from, $fromname, $recipient, $subject, $body, $mode = 0, $cc = null, $bcc = null, $attachment = null, $replyto = null, $replytoname = null ) {
$mail = comprofilerCreateMail( $from, $fromname, $subject, $body );
// activate HTML formatted emails
if ( $mode ) {
$mail->IsHTML(true);
}
if( is_array( $recipient ) ) {
foreach ( $recipient as $to ) {
$mail->AddAddress( $to );
}
} else {
$mail->AddAddress($recipient);
}
if ( isset( $cc ) ) {
if ( is_array( $cc ) ) {
foreach ( $cc as $to ) {
$mail->AddCC( $to );
}
} else {
$mail->AddCC( $cc );
}
}
if ( isset( $bcc ) ) {
if ( is_array( $bcc ) ) {
foreach ($bcc as $to) $mail->AddBCC($to);
} else {
$mail->AddBCC($bcc);
}
}
if ( $attachment ) {
if ( is_array( $attachment ) ) {
foreach ( $attachment as $fname ) {
$mail->AddAttachment($fname);
}
} else {
$mail->AddAttachment( $attachment );
}
}
if ( $replyto ) {
if ( is_array( $replyto ) ) {
reset( $replytoname );
foreach ( $replyto as $to ) {
$toname = ( ( false !== (list( $key, $value ) = each( $replytoname ) ) ) ? $value : '' );
$mail->AddReplyTo( array($to, $toname) );
}
} else
$mail->AddReplyTo( array($replyto, $replytoname) );
}
$mailsSent = $mail->Send();
/*
global $_CB_framework;
if( $_CB_framework->getCfg( 'debug' ) ) {
//$mosDebug->message( "Mails send: $mailssend"«»);
}
if( $mail->error_count > 0 ) {
//$mosDebug->message( "The mail message $fromname <$from> about $subject to $recipient <b>failed</b><br /><pre>$body</pre>", false );
//$mosDebug->message( "Mailer Error: " . $mail->ErrorInfo . "" );
}
*/
return $mailsSent;
}
[/code:1]
Please be sure that you are running a similar configuration to mine and you are not using joomla 1.0.x since this fix is for joomla 1.5
Hope this helps. I do not see how others got SMTP to work since the phpmailer was never told to run IsSMTP(); anywhere in the code.