我无法设置使用PHPMailer类发送的邮件发送的名称。
我编写了以下函数,以便它可以像mail()
函数中php的bulit一样使用。
function pmail($to, $subject, $message, $headers = "", $attachments = "")
{
date_default_timezone_set('Europe/London');
require_once($_SERVER['DOCUMENT_ROOT']."/lib/inc/class.phpmailer.php");
//include($_SERVER['DOCUMENT_ROOT']."/lib/inc/class.smtp.php"); // optional, gets called from within class.phpmailer.php if not already loaded
$defaultEmail = "reply@example.com";
$defaultEmailName = "Web Mailer";
$mail = new PHPMailer();
$mail->IsSMTP(); // telling the class to use SMTP
$mail->Host = "mail.example.com"; // SMTP server
$mail->SMTPDebug = false; // enables SMTP debug information (for testing, 1 = errors and messages, 2 = messages only, false = off)
$mail->SMTPAuth = true; // enable SMTP authentication
//$mail->SMTPSecure = "tls"; // sets the prefix to the servier
$mail->Host = "mail.example.com"; // sets the SMTP server
$mail->Port = 25; // set the SMTP port for the GMAIL server
$mail->Username = "###"; // SMTP account username
$mail->Password = "###"; // SMTP account password
$mail->SetFrom( ($headers['fromEmail'] != "" ? $headers['fromEmail'] : $defaultEmail), ($headers['fromName'] != "" ? $headers['fromName'] : $defaultEmailName) );
$mail->AddReplyTo( ($headers['replyToEmail'] != "" ? $headers['replyToEmail'] : $defaultEmail), ($headers['replyToName'] != "" ? $headers['replyToName'] : $defaultEmailName) );
$mail->AddAddress($to);
$mail->Subject = $subject;
$mail->AltBody = "To view the message, please use an HTML compatible email viewer!"; // optional, comment out and test
$mail->MsgHTML($message);
foreach($attachments as $attachment) {
//$mail->AddAttachment("images/phpmailer.gif"); // attachment example
$mail->AddAttachment($attachment);
}
if(!$mail->Send()) {
//echo "Mailer Error: ".$mail->ErrorInfo;
return false;
} else {
//echo "Message sent!";
return true;
}
}
用类似的东西进行测试时;
pmail("test@test.com", "test email", "test message here");
一切正常,来自地址的标题中的reply@example.com
按预期显示,但我在收件人的收件箱中看到的名称不是Web Mailer
,而是与该关联的默认帐户用户whos凭据用于发送电子邮件。
在标题中,from name确实显示为Web Mailer,但它是我希望看到它的收件箱
我们无法在系统上设置更多用户帐户,以便我们只使用所需的名称和电子邮件制作新帐户,因此我们必须通过现有的用户帐户发送。 在这种情况下,我的电子邮件会随附我的名字而发送,但我们希望该名称显示为Web Mailer。
这甚至可能吗?
答案 0 :(得分:3)
我曾经使用过这个PHP代码并且效果很好:(它显示的是下面的内容,而不是我的gmail凭据)
$headers = "From: Cartrader UK <noreply@cartrader.co.uk";
。 。
if (mail($to, $subject, $msg, $headers)) {
echo "Mail sent successfully";
} else {
echo "There was some problem sending the E-Mail";
}
也许它可以帮到你。
编辑: 我会尝试使用SetFrom将您的行更改为:
$mail->SetFrom($defaultEmail,$defaultEmailName);
答案 1 :(得分:3)
结果我的功能按预期工作。 因为我收到了从这个系统到内部地址的电子邮件,所以他们都自动将我放在他们的地址簿中,因此用于发送电子邮件的地址与我的个人地址相关联,他们看到我的名字而不是“Web Mailer”。
使用外部电子邮件帐户进行测试时,发件人名称已正确列出。
答案 2 :(得分:3)
如果您使用GitHub的PHP Mailer API,您可以使用它来设置发件人名称:
[DEBUG] 2017-05-11 21:23:19.417 [qtp2114444063-24] HttpChannel - COMMIT for /public/index.xhtml on ServerHttpChannelOverHTTP2@30546632{r=1,c=true,a=DISPATCHED,uri=https://www.sub.example.com:8443/public/index.xhtml}#13
200 null HTTP/2.0
Server: Jetty(9.3.z-SNAPSHOT)
Date: Thu, 11 May 2017 20:23:15 GMT
Set-Cookie: JSESSIONID=16vseavvyqxc01s7h9z9gr6et6;Path=/;Secure
Expires: Thu, 01 Jan 1970 00:00:00 GMT
Content-Type: text/html;charset=utf-8
[DEBUG] 2017-05-11 21:23:19.420 [qtp2114444063-24] HttpChannelOverHTTP2 -
HTTP2 Commit Response #13/774690f9:
HTTP/2.0 200 null
Server: Jetty(9.3.z-SNAPSHOT)
Date: Thu, 11 May 2017 20:23:15 GMT
Set-Cookie: JSESSIONID=16vseavvyqxc01s7h9z9gr6et6;Path=/;Secure
Expires: Thu, 01 Jan 1970 00:00:00 GMT
Content-Type: text/html;charset=utf-8
[DEBUG] 2017-05-11 21:23:19.424 [qtp2114444063-24] HttpTransportOverHTTP2 - HTTP2 Response #13:
HTTP/2.0 200
Server: Jetty(9.3.z-SNAPSHOT)
Date: Thu, 11 May 2017 20:23:15 GMT
Set-Cookie: JSESSIONID=16vseavvyqxc01s7h9z9gr6et6;Path=/;Secure
Expires: Thu, 01 Jan 1970 00:00:00 GMT
Content-Type: text/html;charset=utf-8
[DEBUG] 2017-05-11 21:23:19.430 [qtp2114444063-24] HTTP2Session - Sending HeadersFrame@7cb476e2#13{end=false}
[DEBUG] 2017-05-11 21:23:19.431 [qtp2114444063-24] HTTP2Flusher - Appended HeadersFrame@7cb476e2#13{end=false}, frames=1
[DEBUG] 2017-05-11 21:23:19.432 [qtp2114444063-24] HTTP2Flusher - Flushing HTTP2ServerSession@774690f9{l:/192.168.0.3:8443 <-> r:/192.168.0.3:52103,queueSize=1,sendWindow=12582912,recvWindow=65535,streams=1,NOT_CLOSED}
[DEBUG] 2017-05-11 21:23:19.433 [qtp2114444063-24] HTTP2Flusher - Gathered for write HeadersFrame@7cb476e2#13{end=false}
[DEBUG] 2017-05-11 21:23:19.435 [qtp2114444063-24] HpackEncoder - CtxTbl[18913dbf] encoding
[DEBUG] 2017-05-11 21:23:19.437 [qtp2114444063-24] HpackEncoder - encode IdxFieldS1:':status: 200' to '88'
[DEBUG] 2017-05-11 21:23:19.439 [qtp2114444063-24] HTTP2Session - Failure generating frame HeadersFrame@7cb476e2#13{end=false}
java.lang.ArrayIndexOutOfBoundsException: 1
at org.eclipse.jetty.http.PreEncodedHttpField.putTo(PreEncodedHttpField.java:119) ~[project.war:1.0-SNAPSHOT]
at org.eclipse.jetty.server.Dispatcher.forward(Dispatcher.java:202) [project.war:1.0-SNAPSHOT]
at org.eclipse.jetty.server.Dispatcher.forward(Dispatcher.java:74) [project.war:1.0-SNAPSHOT]
at org.ocpsoft.rewrite.servlet.impl.HttpRewriteResultHandler.handleResult(HttpRewriteResultHandler.java:41) [rewrite-servlet-2.0.12.Final.jar:2.0.12.Final]
at org.ocpsoft.rewrite.servlet.RewriteFilter.rewrite(RewriteFilter.java:268) [rewrite-servlet-2.0.12.Final.jar:2.0.12.Final]
at org.ocpsoft.rewrite.servlet.RewriteFilter.doFilter(RewriteFilter.java:188) [rewrite-servlet-2.0.12.Final.jar:2.0.12.Final]
at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1759) [project.war:1.0-SNAPSHOT]
at org.apache.logging.log4j.web.Log4jServletFilter.doFilter(Log4jServletFilter.java:71) [project.war:1.0-SNAPSHOT]
at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1759) [project.war:1.0-SNAPSHOT]
at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:582) [project.war:1.0-SNAPSHOT]
at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:143) [project.war:1.0-SNAPSHOT]
at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:548) [project.war:1.0-SNAPSHOT]
at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:226) [project.war:1.0-SNAPSHOT]
at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1180) [project.war:1.0-SNAPSHOT]
at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:512) [project.war:1.0-SNAPSHOT]
at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:185) [project.war:1.0-SNAPSHOT]
at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1112) [project.war:1.0-SNAPSHOT]
at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:141) [project.war:1.0-SNAPSHOT]
at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:548) [project.war:1.0-SNAPSHOT]
at org.eclipse.jetty.server.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:213) [project.war:1.0-SNAPSHOT]
at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:134) [project.war:1.0-SNAPSHOT]
at org.eclipse.jetty.server.Server.handle(Server.java:534) [project.war:1.0-SNAPSHOT]
at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:320) [project.war:1.0-SNAPSHOT]
at org.eclipse.jetty.server.HttpChannel.run(HttpChannel.java:267) [project.war:1.0-SNAPSHOT]
at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:671) [project.war:1.0-SNAPSHOT]
at org.eclipse.jetty.util.thread.QueuedThreadPool$2.run(QueuedThreadPool.java:589) [project.war:1.0-SNAPSHOT]
at java.lang.Thread.run(Unknown Source) [?:1.8.0_121]
[DEBUG] 2017-05-11 21:23:19.476 [qtp2114444063-24] HTTP2Flusher - Failing, active/queued=1/0
[DEBUG] 2017-05-11 21:23:19.478 [qtp2114444063-24] HTTP2Session - Removed remote HTTP2Stream@5c4616b8#13{sendWindow=12582912,recvWindow=65535,reset=false,CLOSED}
[DEBUG] 2017-05-11 21:23:19.479 [qtp2114444063-24] HttpTransportOverHTTP2 - HTTP2 Response #13 failed to commit
java.lang.ArrayIndexOutOfBoundsException: 1
at org.eclipse.jetty.http.PreEncodedHttpField.putTo(PreEncodedHttpField.java:119) ~[project.war:1.0-SNAPSHOT]
at org.eclipse.jetty.http2.hpack.HpackEncoder.encode(HpackEncoder.java:289) ~[project.war:1.0-SNAPSHOT]
at org.eclipse.jetty.http2.hpack.HpackEncoder.encode(HpackEncoder.java:179) ~[project.war:1.0-SNAPSHOT]
at org.eclipse.jetty.http2.generator.HeadersGenerator.generateHeaders(HeadersGenerator.java:72) ~[project.war:1.0-SNAPSHOT]
at org.eclipse.jetty.http2.generator.HeadersGenerator.generate(HeadersGenerator.java:56) ~[project.war:1.0-SNAPSHOT]
at org.eclipse.jetty.http2.generator.Generator.control(Generator.java:80) ~[project.war:1.0-SNAPSHOT]
at org.eclipse.jetty.http2.HTTP2Session$ControlEntry.generate(HTTP2Session.java:1122) ~[project.war:1.0-SNAPSHOT]
at org.eclipse.jetty.http2.HTTP2Flusher.process(HTTP2Flusher.java:232) [project.war:1.0-SNAPSHOT]
at org.eclipse.jetty.util.IteratingCallback.processing(IteratingCallback.java:241) [project.war:1.0-SNAPSHOT]
at org.eclipse.jetty.util.IteratingCallback.iterate(IteratingCallback.java:224) [project.war:1.0-SNAPSHOT]
at org.eclipse.jetty.http2.HTTP2Session.frame(HTTP2Session.java:668) [project.war:1.0-SNAPSHOT]
at org.eclipse.jetty.http2.HTTP2Session.frames(HTTP2Session.java:640) [project.war:1.0-SNAPSHOT]
at org.eclipse.jetty.http2.HTTP2Stream.headers(HTTP2Stream.java:87) [project.war:1.0-SNAPSHOT]
at org.eclipse.jetty.http2.server.HttpTransportOverHTTP2.commit(HttpTransportOverHTTP2.java:184) [project.war:1.0-SNAPSHOT]
at org.eclipse.jetty.http2.server.HttpTransportOverHTTP2.send(HttpTransportOverHTTP2.java:111) [project.war:1.0-SNAPSHOT]
at org.eclipse.jetty.server.HttpChannel.sendResponse(HttpChannel.java:732) [project.war:1.0-SNAPSHOT]
at org.eclipse.jetty.server.HttpChannel.write(HttpChannel.java:788) [project.war:1.0-SNAPSHOT]
at org.eclipse.jetty.server.HttpOutput.write(HttpOutput.java:235) [project.war:1.0-SNAPSHOT]
at org.eclipse.jetty.server.HttpOutput.write(HttpOutput.java:219) [project.war:1.0-SNAPSHOT]
at org.eclipse.jetty.server.HttpOutput.close(HttpOutput.java:269) [project.war:1.0-SNAPSHOT]
at org.eclipse.jetty.server.HttpWriter.close(HttpWriter.java:49) [project.war:1.0-SNAPSHOT]
at org.eclipse.jetty.server.ResponseWriter.close(ResponseWriter.java:163) [project.war:1.0-SNAPSHOT]
at org.eclipse.jetty.server.Dispatcher.commitResponse(Dispatcher.java:259) [project.war:1.0-SNAPSHOT]
at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:143) [project.war:1.0-SNAPSHOT]
at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:548) [project.war:1.0-SNAPSHOT]
at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:226) [project.war:1.0-SNAPSHOT]
at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1180) [project.war:1.0-SNAPSHOT]
at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:512) [project.war:1.0-SNAPSHOT]
at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:185) [project.war:1.0-SNAPSHOT]
at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1112) [project.war:1.0-SNAPSHOT]
at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:141) [project.war:1.0-SNAPSHOT]
at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:548) [project.war:1.0-SNAPSHOT]
at org.eclipse.jetty.server.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:213) [project.war:1.0-SNAPSHOT]
at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:134) [project.war:1.0-SNAPSHOT]
at org.eclipse.jetty.server.Server.handle(Server.java:534) [project.war:1.0-SNAPSHOT]
at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:320) [project.war:1.0-SNAPSHOT]
at org.eclipse.jetty.server.HttpChannel.run(HttpChannel.java:267) [project.war:1.0-SNAPSHOT]
at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:671) [project.war:1.0-SNAPSHOT]
at org.eclipse.jetty.util.thread.QueuedThreadPool$2.run(QueuedThreadPool.java:589) [project.war:1.0-SNAPSHOT]
at java.lang.Thread.run(Unknown Source) [?:1.8.0_121]
[DEBUG] 2017-05-11 21:23:19.506 [qtp2114444063-24] HttpChannel - Commit failed
java.lang.ArrayIndexOutOfBoundsException: 1
at org.eclipse.jetty.http.PreEncodedHttpField.putTo(PreEncodedHttpField.java:119) ~[project.war:1.0-SNAPSHOT]
at org.eclipse.jetty.http2.hpack.HpackEncoder.encode(HpackEncoder.java:289) ~[project.war:1.0-SNAPSHOT]
at org.eclipse.jetty.http2.hpack.HpackEncoder.encode(HpackEncoder.java:179) ~[project.war:1.0-SNAPSHOT]
at org.eclipse.jetty.http2.generator.HeadersGenerator.generateHeaders(HeadersGenerator.java:72) ~[project.war:1.0-SNAPSHOT]
at org.eclipse.jetty.http2.generator.HeadersGenerator.generate(HeadersGenerator.java:56) ~[project.war:1.0-SNAPSHOT]
at org.eclipse.jetty.http2.generator.Generator.control(Generator.java:80) ~[project.war:1.0-SNAPSHOT]
at org.eclipse.jetty.http2.HTTP2Session$ControlEntry.generate(HTTP2Session.java:1122) ~[project.war:1.0-SNAPSHOT]
at org.eclipse.jetty.http2.HTTP2Flusher.process(HTTP2Flusher.java:232) [project.war:1.0-SNAPSHOT]
at org.eclipse.jetty.util.IteratingCallback.processing(IteratingCallback.java:241) [project.war:1.0-SNAPSHOT]
at org.eclipse.jetty.util.IteratingCallback.iterate(IteratingCallback.java:224) [project.war:1.0-SNAPSHOT]
at org.eclipse.jetty.http2.HTTP2Session.frame(HTTP2Session.java:668) [project.war:1.0-SNAPSHOT]
at org.eclipse.jetty.http2.HTTP2Session.frames(HTTP2Session.java:640) [project.war:1.0-SNAPSHOT]
at org.eclipse.jetty.http2.HTTP2Stream.headers(HTTP2Stream.java:87) [project.war:1.0-SNAPSHOT]
at org.eclipse.jetty.http2.server.HttpTransportOverHTTP2.commit(HttpTransportOverHTTP2.java:184) [project.war:1.0-SNAPSHOT]
at org.eclipse.jetty.util.thread.QueuedThreadPool$2.run(QueuedThreadPool.java:589) [project.war:1.0-SNAPSHOT]
at java.lang.Thread.run(Unknown Source) [?:1.8.0_121]
[DEBUG] 2017-05-11 21:23:19.540 [qtp2114444063-24] HttpTransportOverHTTP2 - HTTP2 Response #13 aborted
[DEBUG] 2017-05-11 21:23:19.542 [qtp2114444063-24] HTTP2Session - Sending ResetFrame@2542701b#13{internal_error}
[DEBUG] 2017-05-11 21:23:19.543 [qtp2114444063-24] HTTP2Connection - Processing failure on HTTP2ServerSession@774690f9{l:/192.168.0.3:8443 <-> r:/192.168.0.3:52103,queueSize=0,sendWindow=12582912,recvWindow=65535,streams=0,NOT_CLOSED}: java.lang.ArrayIndexOutOfBoundsException: 1
[DEBUG] 2017-05-11 21:23:19.544 [qtp2114444063-24] HTTP2Flusher - Terminated
[DEBUG] 2017-05-11 21:23:19.544 [qtp2114444063-24] HTTP2Session - Disconnecting HTTP2ServerSession@774690f9{l:/192.168.0.3:8443 <-> r:/192.168.0.3:52103,queueSize=0,sendWindow=12582912,recvWindow=65535,streams=0,CLOSED}
[DEBUG] 2017-05-11 21:23:19.545 [qtp2114444063-24] SslConnection - shutdownOutput: oshut=false, ishut=false SslConnection@4811bc2d{NOT_HANDSHAKING,eio=-1/-1,di=-1} -> HTTP2ServerConnection@36ae36d5[DecryptedEndPoint@33608c07{/192.168.0.3:52103<->8443,Open,in,out,FI,-,3993/2000000,HTTP2ServerConnection@36ae36d5}->SelectChannelEndPoint@4dd57ced{/192.168.0.3:52103<->8443,Open,in,out,FI,-,3991/2000000,SslConnection@4811bc2d}{io=1/1,kio=1,kro=1}]
[DEBUG] 2017-05-11 21:23:19.548 [qtp2114444063-24] SslConnection - flush b[0]= SslConnection@4811bc2d{NEED_WRAP,eio=-1/-1,di=-1} -> HTTP2ServerConnection@36ae36d5[DecryptedEndPoint@33608c07{/192.168.0.3:52103<->8443,Open,in,out,FI,-,3995/2000000,HTTP2ServerConnection@36ae36d5}->SelectChannelEndPoint@4dd57ced{/192.168.0.3:52103<->8443,Open,in,out,FI,-,3994/2000000,SslConnection@4811bc2d}{io=1/1,kio=1,kro=1}]
[DEBUG] 2017-05-11 21:23:19.550 [qtp2114444063-24] SslConnection - wrap Status = CLOSED HandshakeStatus = NEED_UNWRAP bytesConsumed = 0 bytesProduced = 31 SslConnection@4811bc2d{NEED_UNWRAP,eio=-1/31,di=-1} -> HTTP2ServerConnection@36ae36d5[DecryptedEndPoint@33608c07{/192.168.0.3:52103<->8443,Open,in,OSHUT,FI,-,3998/2000000,HTTP2ServerConnection@36ae36d5}->SelectChannelEndPoint@4dd57ced{/192.168.0.3:52103<->8443,Open,in,out,FI,-,3996/2000000,SslConnection@4811bc2d}{io=1/1,kio=1,kro=1}]
[DEBUG] 2017-05-11 21:23:19.552 [qtp2114444063-24] ChannelEndPoint - flushed 31 SelectChannelEndPoint@4dd57ced{/192.168.0.3:52103<->8443,Open,in,out,FI,-,3998/2000000,SslConnection@4811bc2d}{io=1/1,kio=1,kro=1}
[DEBUG] 2017-05-11 21:23:19.554 [qtp2114444063-27] ManagedSelector - Selector loop woken up from select, 1/1 selected
[DEBUG] 2017-05-11 21:23:19.569 [qtp2114444063-27] SelectChannelEndPoint - onSelected 1->0 r=true w=false for SelectChannelEndPoint@4dd57ced{/192.168.0.3:52103<->8443,Open,in,out,FI,-,4015/2000000,SslConnection@4811bc2d}{io=1/0,kio=1,kro=1}
[DEBUG] 2017-05-11 21:23:19.571 [qtp2114444063-27] SelectChannelEndPoint - Direct readable run SelectChannelEndPoint@4dd57ced{/192.168.0.3:52103<->8443,Open,in,out,FI,-,4017/2000000,SslConnection@4811bc2d}{io=1/0,kio=1,kro=1}
[DEBUG] 2017-05-11 21:23:19.573 [qtp2114444063-27] FillInterest - FillInterest@578f792c{true,SSLC.NBReadCB@4811bc2d{SslConnection@4811bc2d{NEED_UNWRAP,eio=-1/0,di=-1} -> HTTP2ServerConnection@36ae36d5[DecryptedEndPoint@33608c07{/192.168.0.3:52103<->8443,Open,in,OSHUT,FI,-,4020/2000000,HTTP2ServerConnection@36ae36d5}->SelectChannelEndPoint@4dd57ced{/192.168.0.3:52103<->8443,Open,in,out,FI,-,4018/2000000,SslConnection@4811bc2d}{io=1/0,kio=1,kro=1}]}} fillable SSLC.NBReadCB@4811bc2d{SslConnection@4811bc2d{NEED_UNWRAP,eio=-1/0,di=-1} -> HTTP2ServerConnection@36ae36d5[DecryptedEndPoint@33608c07{/192.168.0.3:52103<->8443,Open,in,OSHUT,FI,-,4020/2000000,HTTP2ServerConnection@36ae36d5}->SelectChannelEndPoint@4dd57ced{/192.168.0.3:52103<->8443,Open,in,out,FI,-,4019/2000000,SslConnection@4811bc2d}{io=1/0,kio=1,kro=1}]}
[DEBUG] 2017-05-11 21:23:19.577 [qtp2114444063-24] ChannelEndPoint - oshut SelectChannelEndPoint@4dd57ced{/192.168.0.3:52103<->8443,Open,in,out,-,-,0/2000000,SslConnection@4811bc2d}{io=1/0,kio=1,kro=1}
[DEBUG] 2017-05-11 21:23:19.577 [qtp2114444063-27] SslConnection - onFillable enter DecryptedEndPoint@33608c07{/192.168.0.3:52103<->8443,Open,in,OSHUT,FI,-,4025/2000000,HTTP2ServerConnection@36ae36d5}->SelectChannelEndPoint@4dd57ced{/192.168.0.3:52103<->8443,Open,in,out,-,-,0/2000000,SslConnection@4811bc2d}{io=1/0,kio=1,kro=1}
[DEBUG] 2017-05-11 21:23:19.580 [qtp2114444063-27] FillInterest - FillInterest@123a5f92{true,org.eclipse.jetty.http2.HTTP2Connection$FillCallback@35370707} fillable org.eclipse.jetty.http2.HTTP2Connection$FillCallback@35370707
[DEBUG] 2017-05-11 21:23:19.585 [qtp2114444063-27] HTTP2Connection - HTTP2 onFillable HTTP2ServerConnection@36ae36d5[DecryptedEndPoint@33608c07{/192.168.0.3:52103<->8443,Open,in,OSHUT,-,-,4032/2000000,HTTP2ServerConnection@36ae36d5}->SelectChannelEndPoint@4dd57ced{/192.168.0.3:52103<->8443,Open,in,out,-,-,7/2000000,SslConnection@4811bc2d}{io=1/0,kio=1,kro=1}]
[DEBUG] 2017-05-11 21:23:19.594 [qtp2114444063-27] HTTP2Connection - Dequeued task null
[DEBUG] 2017-05-11 21:23:19.596 [qtp2114444063-27] ChannelEndPoint - filled 46 SelectChannelEndPoint@4dd57ced{/192.168.0.3:52103<->8443,Open,in,OSHUT,FI,-,0/2000000,SslConnection@4811bc2d}{io=1/0,kio=1,kro=1}
[DEBUG] 2017-05-11 21:23:19.598 [qtp2114444063-27] SslConnection - net=46 unwrap Status = OK HandshakeStatus = NEED_UNWRAP bytesConsumed = 46 bytesProduced = 17 SslConnection@4811bc2d{NEED_UNWRAP,eio=0/-1,di=17} -> HTTP2ServerConnection@36ae36d5[DecryptedEndPoint@33608c07{/192.168.0.3:52103<->8443,Open,in,OSHUT,-,-,4046/2000000,HTTP2ServerConnection@36ae36d5}->SelectChannelEndPoint@4dd57ced{/192.168.0.3:52103<->8443,Open,in,OSHUT,FI,-,0/2000000,SslConnection@4811bc2d}{io=1/0,kio=1,kro=1}]
[DEBUG] 2017-05-11 21:23:19.596 [qtp2114444063-24] FillInterest - FillInterest@578f792c{true,AC.ReadCB@4811bc2d{SslConnection@4811bc2d{NEED_UNWRAP,eio=17362/-1,di=0} -> HTTP2ServerConnection@36ae36d5[DecryptedEndPoint@33608c07{/192.168.0.3:52103<->8443,Open,in,OSHUT,-,-,4043/2000000,HTTP2ServerConnection@36ae36d5}->SelectChannelEndPoint@4dd57ced{/192.168.0.3:52103<->8443,Open,in,OSHUT,FI,-,1/2000000,SslConnection@4811bc2d}{io=1/0,kio=1,kro=1}]}} register AC.ReadCB@4811bc2d{SslConnection@4811bc2d{NEED_UNWRAP,eio=17362/-1,di=0} -> HTTP2ServerConnection@36ae36d5[DecryptedEndPoint@33608c07{/192.168.0.3:52103<->8443,Open,in,OSHUT,-,-,4044/2000000,HTTP2ServerConnection@36ae36d5}->SelectChannelEndPoint@4dd57ced{/192.168.0.3:52103<->8443,Open,in,OSHUT,FI,-,1/2000000,SslConnection@4811bc2d}{io=1/0,kio=1,kro=1}]}
[DEBUG] 2017-05-11 21:23:19.601 [qtp2114444063-27] SslConnection - filled b[0]= SslConnection@4811bc2d{NEED_UNWRAP,eio=0/-1,di=17} -> HTTP2ServerConnection@36ae36d5[DecryptedEndPoint@33608c07{/192.168.0.3:52103<->8443,Open,in,OSHUT,-,-,4049/2000000,HTTP2ServerConnection@36ae36d5}->SelectChannelEndPoint@4dd57ced{/192.168.0.3:52103<->8443,Open,in,OSHUT,FI,-,3/2000000,SslConnection@4811bc2d}{io=1/0,kio=1,kro=1}]
[DEBUG] 2017-05-11 21:23:19.608 [qtp2114444063-27] HTTP2Connection - Filled 17 bytes
[DEBUG] 2017-05-11 21:23:19.609 [qtp2114444063-24] SelectChannelEndPoint - changeInterests p=true 0->1 for SelectChannelEndPoint@4dd57ced{/192.168.0.3:52103<->8443,Open,in,OSHUT,FI,-,11/2000000,SslConnection@4811bc2d}{io=1/1,kio=1,kro=1}
[DEBUG] 2017-05-11 21:23:19.611 [qtp2114444063-27] ServerParser - Parsing java.nio.HeapByteBuffer[pos=0 lim=17 cap=8192]
[DEBUG] 2017-05-11 21:23:19.613 [qtp2114444063-24] WriteFlusher - ignored: WriteFlusher@19660642{IDLE} java.nio.channels.ClosedChannelException
[DEBUG] 2017-05-11 21:23:19.614 [qtp2114444063-27] Parser - Parsed GO_AWAY frame header from java.nio.HeapByteBuffer[pos=9 lim=17 cap=8192]
[DEBUG] 2017-05-11 21:23:19.615 [qtp2114444063-24] ChannelEndPoint - close SelectChannelEndPoint@4dd57ced{/192.168.0.3:52103<->8443,CLOSED,in,OSHUT,-,-,17/2000000,SslConnection@4811bc2d}{io=1/1,kio=1,kro=1}
[DEBUG] 2017-05-11 21:23:19.616 [qtp2114444063-27] HTTP2Session - Received GoAwayFrame@2feeab64,0/NO_ERROR/
[DEBUG] 2017-05-11 21:23:19.618 [qtp2114444063-27] HTTP2Session - Ignored GoAwayFrame@2feeab64,0/NO_ERROR/, already closed
[DEBUG] 2017-05-11 21:23:19.618 [qtp2114444063-24] ManagedSelector - Queued change org.eclipse.jetty.io.ManagedSelector$2@aee6275 on org.eclipse.jetty.io.ManagedSelector@bd35a0c id=0 keys=1 selected=1
[DEBUG] 2017-05-11 21:23:19.618 [qtp2114444063-27] Parser - Parsed GO_AWAY frame body from java.nio.HeapByteBuffer[pos=17 lim=17 cap=8192]
[DEBUG] 2017-05-11 21:23:19.619 [qtp2114444063-24] WriteFlusher - ignored: WriteFlusher@1138af6d{IDLE} java.nio.channels.ClosedChannelException
[DEBUG] 2017-05-11 21:23:19.619 [qtp2114444063-27] HTTP2Connection - Dequeued new task null
[DEBUG] 2017-05-11 21:23:19.621 [qtp2114444063-27] SslConnection - net=-1 unwrap Status = BUFFER_UNDERFLOW HandshakeStatus = NEED_UNWRAP bytesConsumed = 0 bytesProduced = 0 SslConnection@4811bc2d{NEED_UNWRAP,eio=0/-1,di=0} -> HTTP2ServerConnection@36ae36d5[DecryptedEndPoint@33608c07{/192.168.0.3:52103<->8443,CLOSED,in,OSHUT,-,-,4069/2000000,HTTP2ServerConnection@36ae36d5}->SelectChannelEndPoint@4dd57ced{/192.168.0.3:52103<->8443,CLOSED,ISHUT,OSHUT,-,-,23/2000000,SslConnection@4811bc2d}{io=1/1,kio=-1,kro=-1}]
[DEBUG] 2017-05-11 21:23:19.620 [qtp2114444063-24] HttpOutput -
java.lang.ArrayIndexOutOfBoundsException: 1
at org.eclipse.jetty.http.PreEncodedHttpField.putTo(PreEncodedHttpField.java:119) ~[project.war:1.0-SNAPSHOT]
at org.eclipse.jetty.http2.hpack.HpackEncoder.encode(HpackEncoder.java:289) ~[project.war:1.0-SNAPSHOT]
at org.eclipse.jetty.http2.hpack.HpackEncoder.encode(HpackEncoder.java:179) ~[project.war:1.0-SNAPSHOT]
at org.eclipse.jetty.http2.generator.HeadersGenerator.generateHeaders(HeadersGenerator.java:72) ~[project.war:1.0-SNAPSHOT]
at org.eclipse.jetty.http2.generator.HeadersGenerator.generate(HeadersGenerator.java:56) ~[project.war:1.0-SNAPSHOT]
at org.eclipse.jetty.http2.generator.Generator.control(Generator.java:80) ~[project.war:1.0-SNAPSHOT]
at org.eclipse.jetty.server.HttpChannel.write(HttpChannel.java:788) ~[project.war:1.0-SNAPSHOT]
at org.eclipse.jetty.server.HttpOutput.write(HttpOutput.java:235) ~[project.war:1.0-SNAPSHOT]
at org.eclipse.jetty.server.HttpOutput.write(HttpOutput.java:219) [project.war:1.0-SNAPSHOT]
at org.eclipse.jetty.server.HttpOutput.close(HttpOutput.java:269) [project.war:1.0-SNAPSHOT]
at org.eclipse.jetty.server.HttpWriter.close(HttpWriter.java:49) [project.war:1.0-SNAPSHOT]
at org.eclipse.jetty.server.ResponseWriter.close(ResponseWriter.java:163) [project.war:1.0-SNAPSHOT]
at org.eclipse.jetty.server.Dispatcher.commitResponse(Dispatcher.java:259) [project.war:1.0-SNAPSHOT]
at org.eclipse.jetty.server.Dispatcher.forward(Dispatcher.java:202) [project.war:1.0-SNAPSHOT]
at org.eclipse.jetty.server.Dispatcher.forward(Dispatcher.java:74) [project.war:1.0-SNAPSHOT]
at org.ocpsoft.rewrite.servlet.impl.HttpRewriteResultHandler.handleResult(HttpRewriteResultHandler.java:41) [rewrite-servlet-2.0.12.Final.jar:2.0.12.Final]
at org.ocpsoft.rewrite.servlet.RewriteFilter.rewrite(RewriteFilter.java:268) [rewrite-servlet-2.0.12.Final.jar:2.0.12.Final]
at org.ocpsoft.rewrite.servlet.RewriteFilter.doFilter(RewriteFilter.java:188) [rewrite-servlet-2.0.12.Final.jar:2.0.12.Final]
at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1759) [project.war:1.0-SNAPSHOT]
at org.apache.logging.log4j.web.Log4jServletFilter.doFilter(Log4jServletFilter.java:71) [project.war:1.0-SNAPSHOT]
at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1759) [project.war:1.0-SNAPSHOT]
at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:582) [project.war:1.0-SNAPSHOT]
at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:143) [project.war:1.0-SNAPSHOT]
at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:548) [project.war:1.0-SNAPSHOT]
at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:226) [project.war:1.0-SNAPSHOT]
at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1180) [project.war:1.0-SNAPSHOT]
at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:512) [project.war:1.0-SNAPSHOT]
at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:185) [project.war:1.0-SNAPSHOT]
at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1112) [project.war:1.0-SNAPSHOT]
at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:141) [project.war:1.0-SNAPSHOT]
at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:548) [project.war:1.0-SNAPSHOT]
at org.eclipse.jetty.server.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:213) [project.war:1.0-SNAPSHOT]
at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:134) [project.war:1.0-SNAPSHOT]
at org.eclipse.jetty.server.Server.handle(Server.java:534) [project.war:1.0-SNAPSHOT]
at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:320) [project.war:1.0-SNAPSHOT]
at org.eclipse.jetty.server.HttpChannel.run(HttpChannel.java:267) [project.war:1.0-SNAPSHOT]
at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:671) [project.war:1.0-SNAPSHOT]
at org.eclipse.jetty.util.thread.QueuedThreadPool$2.run(QueuedThreadPool.java:589) [project.war:1.0-SNAPSHOT]
at java.lang.Thread.run(Unknown Source) [?:1.8.0_121]
[DEBUG] 2017-05-11 21:23:19.623 [qtp2114444063-27] SslConnection - filled b[0]= SslConnection@4811bc2d{NEED_UNWRAP,eio=0/-1,di=0} -> HTTP2ServerConnection@36ae36d5[DecryptedEndPoint@33608c07{/192.168.0.3:52103<->8443,CLOSED,in,OSHUT,-,-,4071/2000000,HTTP2ServerConnection@36ae36d5}->SelectChannelEndPoint@4dd57ced{/192.168.0.3:52103<->8443,CLOSED,ISHUT,OSHUT,-,-,25/2000000,SslConnection@4811bc2d}{io=1/1,kio=-1,kro=-1}]
[DEBUG] 2017-05-11 21:23:19.652 [qtp2114444063-24] HttpTransportOverHTTP2 - HTTP2 Response #13 aborted
答案 3 :(得分:-1)
您可以在mail.php中设置
$headers = "From: Your Name <yourname@example.com>";