• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
CI and Mercury SMTP

#1
[eluser]Total Shop UK[/eluser]
If I use CI mail to send an email I get an error in Mercury SMTP as shown below.

30 Apr 10 11:33, Servicing job MO000166... 553 5.0.0 <<[email protected]> SIZE 1103... Unbalanced '<'

Code:
$html = 'This is a <b>html</b> test';
$text = 'This is a text test';
$from_email = '[email protected]';
$to = '[email protected]';
$subject = 'Test Subject';
$this->load->library('email');
$config['charset'] = 'iso-8859-1';
$config['wordwrap'] = TRUE;
$config['mailtype'] = 'html';
$this->email->initialize($config);
$this->email->from($from_email);
$this->email->to($to);
$this->email->subject($subject);
$this->email->message($html);
$this->email->set_alt_message($text);
$this->email->send();

But if I use the standard mail() it works fine.

30 Apr 10 11:35, Servicing job MO00016E... OK.

Code:
$header = "From: [email protected]"."\r\n";
mail('[email protected]', 'Test Subject', 'This is a text test', $header);

Any ideas?

#2
[eluser]InsiteFX[/eluser]
Did you create an email.php config file and set it up for sending SMTP?

CodeIgniter User Guide - EMAIL

Code:
smtp_host No Default None SMTP Server Address.
smtp_user No Default None SMTP Username.
smtp_pass No Default None SMTP Password.
smtp_port 25 None SMTP Port.
smtp_timeout 5 None SMTP Timeout (in seconds).

InsiteFX

#3
[eluser]Total Shop UK[/eluser]
My local SMTP server requires no auth, mail just has to come from a local address.
It is then relayed through a paid SMTP server.

Everything seems to be working but for some unknown reason CI is adding an extra < around the from address which the Mercury SMTP server doesn't like.

All that you see above is what I am using, so there is no email.php config file, just PHP.ini set for SMTP.

#4
[eluser]InsiteFX[/eluser]
Code:
Try removing this <b>html</b> from your $html, it may think that it's trying to escape it.

InsiteFX

#5
[eluser]Total Shop UK[/eluser]
I have tried sending the below with the same issue.. it's very strange??

The only other discussion I can find on this unbalanced issue is here - http://community.pmail.com/forums/thread/8021.aspx

Code:
$text = 'This is a text test';
$from_email = '[email protected]';
$to = '[email protected]';
$subject = 'Test Subject';
$this->load->library('email');
$config['charset'] = 'iso-8859-1';
$config['wordwrap'] = TRUE;
$config['mailtype'] = 'text';
$this->email->initialize($config);
$this->email->from($from_email);
$this->email->to($to);
$this->email->subject($subject);
$this->email->message($text);
$this->email->send();

#6
[eluser]InsiteFX[/eluser]
Maybe the email library is corrupted or CI I have had this happen
to me several times were I had to re-install.

InsiteFX

#7
[eluser]Total Shop UK[/eluser]
I wouldn't have even though about that. Now going to download a fresh copy and see what happens. Thanks

#8
[eluser]Total Shop UK[/eluser]
Okay it's not that Sad
Fresh copy of CI v1.7.2 and I get the message below, yet mail() still seems to work.
Either Mercury SMTP should accept something that it's not or CI is send something that it shouldn't??

30 Apr 10 16:40, Servicing job MO000012... 553 5.0.0 <<[email protected]> SIZE=711... Unbalanced '<'

Code:
$this->load->library('email');
$this->email->from('[email protected]');
$this->email->to('[email protected]');
$this->email->subject('Test Subject');
$this->email->message('This is a text test');
$this->email->send();

#9
[eluser]Total Shop UK[/eluser]
I've had a reply from the guys at Mercury SMTP:-

Yes, the mailer is broken. The MAIL FROM: e-mail address is supposed to be a simple SMTP e-mail address enclosed in <> without the Personal name part. This gets removed in the receiving process but the leading "<" does not and so you have an unbalanced address. Then the mail is forwarded on to the outside world this unbalanced address is refused. You need to fix your PHP program to only use the e-mail address in the MAIL FROM: string.

FWIW, it looks like your mailer application is using the From: field entry for both the From: and MAIL FROM:, this needs to be fixed.

Second Reply

The mailer script seems rather broken. In addition to what Thomas has already said the header name for the Subject header is missing, as well as the required blank line between headers and message body.

http://community.pmail.com/forums/thread/23242.aspx


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2021 MyBB Group.