我收到一封带有标题和最后一行的电子邮件。为什么不是所有的行?
这是我的完整代码:
$email_from = 'info@email.com';
$email_to = $row['email'];
$email_subject = "The " . $row['event'] . " Registration";
$email_message .= "Dear " . $row['lname'] . " " . $row['fname'] . "\n" ;
$email_message .= "This is a notice that an invoice for your order has been generated on " . $row['reg_date'] . "\n" ;
$email_message .= "Your payment method is: " . $row['payment'] . "\n" ;
$email_message .= "Invoice: " . $row['id'] . "\n" ;
$email_message .= "Status: Unpaid \n" ;
$email_message .= "<strong>Invoice Items</strong> \n" ;
$email_message .= "Event: " . $row['event'] . "\n" ;
$email_message .= "<hr> \n" ;
$email_message .= "<hr> \n" ;
$email_message .= "Here is your Invoice id: ".$row['ref']. "\n" ;
// create email headers
$headers = 'From: '.$email_from."\r\n".
'Reply-To: '.$email_from."\r\n" .
'X-Mailer: PHP/' . phpversion();
@mail($email_to, $email_subject, $email_message, $headers);
我想像这样发送电子邮件
Dear Dasgupta Arnab
This is a notice that an invoice for your order has been generated on: date
Your payment method is: whatever
Invoice: 123456
Status: Unpaid
Invoice Items
Event: event name
Here is your Invoice: refid
但我只是在电子邮件中得到这样的内容
Here is your Invoice: refid
答案 0 :(得分:0)
试试这个:
$email_from = 'info@email.com';
$email_to = $row['email'];
$email_subject = "The " . $row['event'] . " Registration";
$email_message="";
$email_message .= "Dear " . $row['lname'] . " " . $row['fname'] . "\n" ;
$email_message .= "This is a notice that an invoice for your order has been generated on " . $row['reg_date'] . "\n" ;
$email_message .= "Your payment method is: " . $row['payment'] . "\n" ;
$email_message .= "Invoice: " . $row['id'] . "\n" ;
$email_message .= "Status: Unpaid \n" ;
$email_message .= "<strong>Invoice Items</strong> \n" ;
$email_message .= "Event: " . $row['event'] . "\n" ;
$email_message .= "<hr> \n" ;
$email_message .= "<hr> \n" ;
$email_message .= "Here is your Invoice id: ".$row['ref']. "\n" ;
// create email headers
$headers = 'From: '.$email_from."\r\n".
'Reply-To: '.$email_from."\r\n" .
'X-Mailer: PHP/' . phpversion();
@mail($email_to, $email_subject, $email_message, $headers);
答案 1 :(得分:0)
我试过这段代码:
$row = ['email' => 'test@test.com', 'lname' => 'Testname', 'payment' => 'Invoice', 'id' => '1', 'event' => 'sold', 'ref' => '111222333'];
$email_from = 'info@email.com';
$email_to = $row['email'];
$email_subject = 'The ' . $row['event'] . ' Registration';
$email_message = '';
$email_message .= 'Dear ' . $row['lname'] . ' ' . $row['fname'] . "\n";
$email_message .= 'This is a notice that an invoice for your order has been generated on ' . $row['reg_date'] . "\n";
$email_message .= 'Your payment method is: ' . $row['payment'] . "\n";
$email_message .= 'Invoice: ' . $row['id'] . "\n";
$email_message .= "Status: Unpaid\n";
$email_message .= "<strong>Invoice Items</strong>\n";
$email_message .= 'Event: ' . $row['event'] . "\n";
$email_message .= "<hr>\n";
$email_message .= "<hr>\n";
$email_message .= 'Here is your Invoice id: ' . $row['ref'] . "\n";
// create email headers
$headers = 'From: ' . $email_from . "\r\n" .
'Reply-To: ' . $email_from . "\r\n" .
'X-Mailer: PHP/' . phpversion();
@mail($email_to, $email_subject, $email_message, $headers);
生成的电子邮件信息如下:
Received: from spooler by 127.0.0.1 (Mercury/32 v4.62); 30 May 2018 08:51:35 +0200
Received: from L-PC.DOMAIN.LOCAL (127.0.0.1) by 127.0.0.1 (Mercury/32 v4.62) ID MG000001;
30 May 2018 08:51:33 +0200
Date: Wed, 30 May 2018 08:51:33 +0200
Subject: The sold Registration
To: test@test.com
X-PHP-Originating-Script: 0:index.php
From: info@email.com
Reply-To: info@email.com
X-Mailer: PHP/7.2.3
Message-ID: <3DE5C9E94CE0@127.0.0.1>
Dear Testname
This is a notice that an invoice for your order has been generated on
Your payment method is: Invoice
Invoice: 1
Status: Unpaid
<strong>Invoice Items</strong>
Event: sold
<hr>
<hr>
Here is your Invoice id: 111222333
如果它在您的网站上不起作用,则会出现其他问题。