How do I specify SMTP server for an e-mail in PHP?

后端 未结 2 1045
陌清茗
陌清茗 2021-01-27 07:07

I want to send an e-mail through a PHP script in Linux. My code is as follows:

$to = $row[\'EmailID\'];
$subject = \"XYZ\";
$message = \"yes!!!!\";
$from = \"pal         


        
2条回答
  •  Happy的楠姐
    2021-01-27 07:48

    Taken from: http://board.phpbuilder.com/showthread.php?10307560-CONFIGURING-php-ini-(Setting-the-SMTP)!!!

    smtp= the name of the host where the SMTP server you'll be using is running (whoever's responsible for your network connection should know this) smtp_port= the port on that host the SMTP server is listening on (25 is the conventional choice) sendmail_from= the email address that the sent mail should say it's from

    Just configure the above in your php.ini file.

    [Edit] to reflect my comment:- if you dont have access to the default php.ini file, you can create one in your webroot and drop this in.

    [Edit 2] This does depend on the configuation on the server, most hosts will allow it however.

提交回复
热议问题