smtp FROM contains SPACE then shows error: Bad sender address syntax

49 views
Skip to first unread message

FreeFAT

unread,
Sep 16, 2017, 4:29:23 AM9/16/17
to f3-fra...@googlegroups.com
Hi,

I do need your help!!! 

I have a class to send email via smtp. 

class Mail extends Controller {

private $host = "mail.server.com";
private $port = 587;
private $scheme = "tls";
private $username = "us...@server.com";
private $password = "pwd";
    function index(){
$f3 = $this->f3;
$smtp = new SMTP ( $this->host, $this->port, $this->scheme, $this->username, $this->password );
$smtp->set('From',"'Antonio Banderas <{$this->username}>");
$smtp->set('To', 'ot...@server.com');
$smtp->set('Subject', 'Test mail');
$smtp->send("Meesage");
echo '<pre>'.$smtp->log().'</pre>';
}
}

When I use space in FROM header it doesn't send an email it shows in log:

235 2.7.0 Authentication successful
MAIL FROM: , , 
501 5.1.7 Bad sender address syntax
RCPT TO: 
503 5.5.1 Error: need MAIL command
DATA
503 5.5.1 Error: need RCPT command
QUIT

but if use like (without space) $smtp->set('From', $this->username); it works fine and sends an email.

WHAT TO DO?  I need to show in From headers who sent an email. Help please!!!

ikkez

unread,
Sep 16, 2017, 5:12:37 AM9/16/17
to f3-fra...@googlegroups.com
I think it's
$smtp->set("To", '"Antonio Banderas" <ma...@domain.com>, "Ridley Scott" <ma...@domain.com>');

FreeFAT

unread,
Sep 16, 2017, 5:16:23 AM9/16/17
to Fat-Free Framework
YES!!! YES!!! YES!!!!

I think it's 
$smtp->set("From", '"Antonio Banderas" <ma...@domain.com>');

THANK YOU SO MUCH!!!
Reply all
Reply to author
Forward
0 new messages