[Typo3] How to make "Front End User Registration" ext send mail viamy ISP's SMTP server which requires authentication?

Omar Zuberi Omar.Zuberi at osellus.com
Mon Mar 7 15:08:56 CET 2005


Dear Tracy,

I ran into the same issue, and I don't remember ever receiving a reply
on this post ... I guess my question was too vuage.  But I managed to
remedy the issue with some php coding in the class files (I can't think
of any other fix).

The following are my step by step notes on what I did, I hope I didn't
leave anything out.

To implement email w/smtp authentication in Typo3, must download and
install iwi_phpmail extension.

=> replace the following in class.t3lib_div.php

function
plainMailEncoded($email,$subject,$message,$headers='',$enc='',$charset='
ISO-8859-1',$dontEncodeSubject=0)	{
		switch((string)$enc)	{
			case 'base64':
				$headers=trim($headers).chr(10).
				'Mime-Version: 1.0'.chr(10).
				'Content-Type: text/plain;
charset="'.$charset.'"'.chr(10).
				'Content-Transfer-Encoding: base64';

	
$message=trim(chunk_split(base64_encode($message.chr(10)))).chr(10);
// Adding chr(10) because I think MS outlook 2002 wants it... may be
removed later again.

				if (!$dontEncodeSubject)
$subject='=?'.$charset.'?B?'.base64_encode($subject).'?=';
			break;
			case 'quoted-printable':
				$headers=trim($headers).chr(10).
				'Mime-Version: 1.0'.chr(10).
				'Content-Type: text/plain;
charset="'.$charset.'"'.chr(10).
				'Content-Transfer-Encoding:
quoted-printable';

	
$message=t3lib_div::quoted_printable($message);

				if (!$dontEncodeSubject)
$subject='=?'.$charset.'?Q?'.trim(t3lib_div::quoted_printable(ereg_repla
ce('[[:space:]]','_',$subject),1000)).'?=';
			break;
			case '8bit':
				$headers=trim($headers).chr(10).
				'Mime-Version: 1.0'.chr(10).
				'Content-Type: text/plain;
charset="'.$charset.'"'.chr(10).
				'Content-Transfer-Encoding: 8bit';
			break;
		}
	
$headers=trim(implode(chr(10),t3lib_div::trimExplode(chr(10),$headers,1)
));	// make sure no empty lines are there.

		mail($email,$subject,$message,$headers);
	}


With


function
plainMailEncoded($email,$subject,$message,$headers='',$enc='',$charset='
ISO-8859-1',$dontEncodeSubject=0) 
{
 
$headers=trim(implode(chr(10),t3lib_div::trimExplode(chr(10),$headers,1)
));
        $mail = t3lib_div::makeInstance("iwi_phpmail");//[ia] fix
        $mail->From     = "mayontester at osellus.com";
        $mail->FromName = "Typo3TestSite";
        $mail->AddAddress($email,''); 

        $mail->IsHTML(true);                               // send as
HTML

        $mail->Subject  =  $subject;
        $mail->Body     =  '<pre>'.$message.'</pre>';

        if(!$mail->Send())
        {
          echo "Message was not sent <p>";
          echo "Mailer Error: " . $mail->ErrorInfo;
        }
}

=> add
require_once(PATH_typo3conf.'ext/iwi_phpmail/class.iwi_phpmail.php');
before 
class t3lib_div {
in class.t3lib_div.php

=> edit class.iwi_phpmail.php to look like this

function iwi_phpmail()					//constructor
{
							//typo3 settings
        $this->Mailer   = "mail";
        $this->CharSet =
($GLOBALS['TSFE']->config['config']['metaCharset'])?($GLOBALS['TSFE']->c
onfig['config']['metaCharset']):('charset=iso-8859-1');

        $this->IsSMTP();				// send via SMTP
	$this->Host = "you.domain.name";		// SMTP servers
	$this->SMTPAuth = true;				// turn on SMTP
authentication
	$this->Username = "username";		// SMTP username
	$this->Password = "password";			// SMTP password

 
$this->SetLanguage("en",dirname(__FILE__).'/phpmailer-1.72/language/');	
        $this->Encoding = 'quoted-printable';
        $mail->From     = "user at domain.name";
        $mail->FromName = "Typo3TestSite";
}


=> replace in class.tx_srfeuserregister_pi1.php

		function sendHTMLMail($HTMLContent, $PLAINContent,
$recipient, $dummy, $fromEmail, $fromName, $replyTo = '',
$fileAttachment = '') {
			// HTML
			if (trim($recipient)) {
				$parts = spliti('<title>|</title>',
$HTMLContent, 3);
				$subject = trim($parts[1]) ?
strip_tags(trim($parts[1])) :
				'Front end user registration message';
				 
				$Typo3_htmlmail =
t3lib_div::makeInstance('tx_srfeuserregister_pi1_t3lib_htmlmail');
				$Typo3_htmlmail->charset =
$this->charset;
				$Typo3_htmlmail->start();
				$Typo3_htmlmail->messageid =
md5(microtime());
				$Typo3_htmlmail->mailer = 'Typo3
HTMLMail';		 
				$Typo3_htmlmail->subject =
$Typo3_htmlmail->convertName($subject);
				$Typo3_htmlmail->from_email =
$fromEmail;
				$Typo3_htmlmail->from_name = $fromName;
				$Typo3_htmlmail->from_name = implode(' '
, t3lib_div::trimExplode(',', $Typo3_htmlmail->from_name));
				$Typo3_htmlmail->replyto_email =
$replyTo ? $replyTo :$fromEmail;
				$Typo3_htmlmail->replyto_name = $replyTo
? '' : $fromName;
				$Typo3_htmlmail->replyto_name =
implode(' ' , t3lib_div::trimExplode(',',
$Typo3_htmlmail->replyto_name));
				$Typo3_htmlmail->organisation = '';
				$Typo3_htmlmail->priority = 3;
				 
				// ATTACHMENT
				if ($fileAttachment &&
file_exists($fileAttachment)) {
	
$Typo3_htmlmail->addAttachment($fileAttachment);
				}
				 
				// HTML
				if (trim($HTMLContent)) {
	
$Typo3_htmlmail->theParts['html']['content'] = $HTMLContent;
	
$Typo3_htmlmail->theParts['html']['path'] = '';
	
$Typo3_htmlmail->extractMediaLinks();
	
$Typo3_htmlmail->extractHyperLinks();
	
$Typo3_htmlmail->fetchHTMLMedia();
	
$Typo3_htmlmail->substMediaNamesInHTML(0); // 0 = relative
	
$Typo3_htmlmail->substHREFsInHTML();
					 
	
$Typo3_htmlmail->setHTML($Typo3_htmlmail->encodeMsg($Typo3_htmlmail->the
Parts['html']['content']));
				}
				 
				// PLAIN
	
$Typo3_htmlmail->addPlain($PLAINContent);
				 
				// SET Headers and Content
				$Typo3_htmlmail->setHeaders();
				$Typo3_htmlmail->setContent();
	
$Typo3_htmlmail->setRecipient($recipient);
				$Typo3_htmlmail->sendtheMail();

			}
		}


With


		function sendHTMLMail($HTMLContent, $PLAINContent,
$recipient, $dummy, $fromEmail, $fromName, $replyTo = '',
$fileAttachment = '') {
			// HTML
			if (trim($recipient)) {
				$parts = spliti('<title>|</title>',
$HTMLContent, 3);
				$subject = trim($parts[1]) ?
strip_tags(trim($parts[1])) :
				'Front end user registration message';
				$oldstuff =
t3lib_div::makeInstance('tx_srfeuserregister_pi1_t3lib_htmlmail');

				$Typo3_htmlmail =
t3lib_div::makeInstance("iwi_phpmail");//[ia] fix
				$Typo3_htmlmail->CharSet =
$this->charset;

				$Typo3_htmlmail->From = $fromEmail;
				$Typo3_htmlmail->FromName = $fromName;

				$Typo3_htmlmail->AddReplyTo ($replyTo ?
$replyTo :$fromEmail, $replyTo ? '' : $fromName);
				$Typo3_htmlmail->AddAddress($recipient);
				
				if ($fileAttachment &&
file_exists($fileAttachment)) {
	
$Typo3_htmlmail->AddAttachment($fileAttachment);
				}

				$Typo3_htmlmail->Subject =
$oldstuff->convertName($subject);

				if (trim($HTMLContent)) {
					$Typo3_htmlmail->IsHTML(true);
// send as HTML

	
$oldstuff->theParts['html']['content'] = $HTMLContent;
	
$oldstuff->theParts['html']['path'] = '';
					$oldstuff->extractMediaLinks();
					$oldstuff->extractHyperLinks();
					$oldstuff->fetchHTMLMedia();
	
$oldstuff->substMediaNamesInHTML(0); // 0 = relative
					$oldstuff->substHREFsInHTML();
					 
	
$oldstuff->setHTML($oldstuff->encodeMsg($oldstuff->theParts['html']['con
tent']));
				}

				$Typo3_htmlmail->Body = $HTMLContent;	
				$Typo3_htmlmail->AltBody =
$PLAINContent;	//alternate text only body

				$Typo3_htmlmail->Send();

			}
		}

=> change line 1889 in tx_srfeuserregister_pi1_tmpl.tmpl from (OPTIONAL)

<input type="hidden" name="redirect_url" value="" />

to

<input type="hidden" name="redirect_url" value="###SITE_URL###" />

 

-----Original Message-----
From: typo3-english-bounces at lists.netfielders.de
[mailto:typo3-english-bounces at lists.netfielders.de] On Behalf Of Tracy
Li
Sent: Monday, March 07, 2005 12:58 AM
To: typo3-english at lists.netfielders.de
Subject: [Typo3] How to make "Front End User Registration" ext send mail
viamy ISP's SMTP server which requires authentication?

Dear all,

Have just installed the "Front End User Registration" ext. Our mail
service is hosted by our ISP and therefore, I've modified the following
lines in "C:\apache\php\php.ini":

[mail function]
; For Win32 only.
SMTP = <SMTP server IP address of our ISP>

; For Win32 only.
sendmail_from = <My email address provided by our ISP>

Our ISP's SMTP server requires both user name and password for
authentication purpose. I can't figure out how I could set the password
info. Any advice would be appreciated. Thanks in advance.


Best regards,
Tracy
_______________________________________________
Typo3-english mailing list
Typo3-english at lists.netfielders.de
http://lists.netfielders.de/cgi-bin/mailman/listinfo/typo3-english



More information about the TYPO3-english mailing list