OJS 2.4.8-1 SMTP settings

I’m having a issue with SMTP setting. Since I’m running OJS (2.4.8-1) on a commercial server, I’m not able to use mail() function and I really need to setup an external SMTP server to send emails.
It didn’t work. I telnet tested my hosting provider’s SMTP server and I’ve been able to authenticate (PLAIN method, 587 port), but with some difficulties. I had to base64 encode userid and pwd using the following trick I found here.
I had to run
perl -MMIME::Base64 -e ‘print encode_base64("\000user@domain\000password")’
Without the “\000” prefix and the escaping of @, authentication was rejected. With both it succeded.
I read this was due to perl interpreter. I tried all possible combinations of userid and pwd in config.inc.php but could not get it to work.
I tried to figure out what the problem was and I read the file /lib/classes/mail/SMTPMailer.inc.php where I found the lines for AUTH PLAIN (250 and following:

 * Authenticate using PLAIN.
 * @return boolean
function authenticate_plain() {
    $authString = $this->username . chr(0x00) . $this->username . chr(0x00) . $this->password;
    if (!$this->send('AUTH', 'PLAIN ' . base64_encode($authString)))
        return false;
    return $this->receive('235');

Is the variable $authString well defined? Why is there a repetition of $this->username . chr(0x00)?
Please forgive my naive questions: I’m not a developer at all: I’m an anthropologist trying to setup a scholarly journal.

The section “AUTH PLAIN” on this SMTP Authentication tutorial describes the syntax as:

The client sends the authorization identity (identity to login as), followed by a US-ASCII NulL character, followed by the authentication identity (identity whose password will be used), followed by a US-ASCII NulL character, followed by the clear-text password.

Can you manually authenticate in perl with that syntax?

Thanks for the quick reply. I’ve been able to authenticate in a telnet session following SMTP Authentication tutorial.

telnet smtp.domain 587
Trying xxx.xxx.xx.xx…
Connected to smtp…
Escape character is ‘^]’.
220 smtp-out…com ESMTP server ready
EHLO smtp.domain
250-smtp-out…com hello [xx.xx.xxx.xxx], pleased to meet you
250-SIZE 209715200
250 OK

I did send the base64 encoded strings produced with the following perl commands:

perl -MMIME::Base64 -e ‘print encode_base64(“user@domain\0user@domain\0password”)’
perl -MMIME::Base64 -e ‘print encode_base64(“user@domain\000user@domain\000password”)’
perl -MMIME::Base64 -e ‘print encode_base64("\0user@domain\0password")’
perl -MMIME::Base64 -e ‘print encode_base64("\000user@domain\000password")’

All of them worked fine, i.e. produced a string that caused a
235 2.7.0 PLAIN authentication successful

I guess that the problem is in php base64 encoding of the string. The hosting provider force a special character inside the password of the mail account I’m trying to use. This probably results in php interpreting uncorrectly the string
I tried with a different account and I finally could figure out what the problem was. It succeeded.

Thank you for your kind assistance.
Best regards
Gino Satta