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

后端 未结 2 1022
陌清茗
陌清茗 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条回答
  • 2021-01-27 07:37

    You can specify your SMTP server in your php.ini file

    Check this thread for example: http://board.phpbuilder.com/showthread.php?10307560-CONFIGURING-php-ini-%28Setting-the-SMTP%29!!!

    If you want to do it inline, you can try changing these settings with ini_set();

    0 讨论(0)
  • 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.

    0 讨论(0)
提交回复
热议问题