开发者

PHP mail body construct

I can't seem to join (concatenate) these fields correctly. Basically we are using a mail api to a 3开发者_如何学Pythonrd party back end and we can't change their fields. So to add new fields we need to add them to the comments section. I want to add

log in id ($loginID) 
their $internal=$_SERVER['SERVER_ADDR'];
$hostname = gethostbyaddr($_SERVER['REMOTE_ADDR']);

to the comments field $inquiry = $_POST['TextField'] ;

I need to format it as follows in the generated email:

Log in - xyz

Host name - xxxx

Internal IP - xxx

Comments - a;ldkjfalkdjf

Currently I have the following code, which when joined together returns nothing

$loginID = $_POST['loginID'] ;
$internal=$_SERVER['SERVER_ADDR'];
$hostname = gethostbyaddr($_SERVER['REMOTE_ADDR']);
$inquiry = $_POST['$loginID' . '$internal' . '$hostname' . 'TextField'] ;

mail( "email@email.com", "subject",
"$inquiry"
"From: $email");

How can I group the desired data and format it better in the return email? thx!


$inquiry = $_POST['$loginID' . '$internal' . '$hostname' . 'TextField'] ;

That line looks wrong. I think you mean:

$inquiry = $_POST['loginID'] . $internal . $hostname . $_POST['TextField'] ;

Or to format it like you said:

$inquiry = 'Log In - '.$_POST['loginID'].PHP_EOL;
$inquiry .= 'Host name - '.$hostname.PHP_EOL;
$inquiry .= 'Internal IP - '.$internal.PHP_EOL;
$inquiry .= 'Comments - : '.$_POST['TextField'].PHP_EOL;


You have to be careful how you are structuring $inquiry:

Message to be sent.

Each line should be separated with a LF (\n). Lines should not be larger than 70 characters.

Caution (Windows only) When PHP is talking to a SMTP server directly, if a full stop is found on the start of a line, it is removed. To counter-act this, replace these occurrences with a double dot.

PHP Mail Function

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜