我試圖發送smtp
請求到freebsd
中安裝的smtp
服務器並讀取成功或失敗響應? 這是我的代碼:如何發送SMTP請求並使用php curl讀取響應?
$url = '192.168.1.227:25/';
$user = 'admin';
$pass = '123';
$params = array(
'User' => $user,
'passwor' => $pass,
'to' => '[email protected]',
'subject' => 'test',
'html' => 'body',
'text' => 'text',
'from' => '[email protected]',
);
$session = curl_init($url);
curl_setopt ($session, CURLOPT_POST, true);
curl_setopt ($session, CURLOPT_POSTFIELDS, $params);
curl_setopt($session, CURLOPT_HEADER, 1);
curl_setopt($session, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($session);
$info = curl_getinfo($session);
curl_close($session);
echo $response;
print_r($info);