Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F479950
PhabricatorMailTarget.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
3 KB
Referenced Files
None
Subscribers
None
PhabricatorMailTarget.php
View Options
<?php
final
class
PhabricatorMailTarget
extends
Phobject
{
private
$viewer
;
private
$replyTo
;
private
$toMap
=
array
();
private
$ccMap
=
array
();
private
$rawToPHIDs
;
private
$rawCCPHIDs
;
public
function
setRawToPHIDs
(
array
$to_phids
)
{
$this
->
rawToPHIDs
=
$to_phids
;
return
$this
;
}
public
function
setRawCCPHIDs
(
array
$cc_phids
)
{
$this
->
rawCCPHIDs
=
$cc_phids
;
return
$this
;
}
public
function
setCCMap
(
array
$cc_map
)
{
$this
->
ccMap
=
$cc_map
;
return
$this
;
}
public
function
getCCMap
()
{
return
$this
->
ccMap
;
}
public
function
setToMap
(
array
$to_map
)
{
$this
->
toMap
=
$to_map
;
return
$this
;
}
public
function
getToMap
()
{
return
$this
->
toMap
;
}
public
function
setReplyTo
(
$reply_to
)
{
$this
->
replyTo
=
$reply_to
;
return
$this
;
}
public
function
getReplyTo
()
{
return
$this
->
replyTo
;
}
public
function
setViewer
(
$viewer
)
{
$this
->
viewer
=
$viewer
;
return
$this
;
}
public
function
getViewer
()
{
return
$this
->
viewer
;
}
public
function
sendMail
(
PhabricatorMetaMTAMail
$mail
)
{
$viewer
=
$this
->
getViewer
();
$mail
->
addPHIDHeaders
(
'X-Phabricator-To'
,
$this
->
rawToPHIDs
);
$mail
->
addPHIDHeaders
(
'X-Phabricator-Cc'
,
$this
->
rawCCPHIDs
);
$to_handles
=
$viewer
->
loadHandles
(
$this
->
rawToPHIDs
);
$cc_handles
=
$viewer
->
loadHandles
(
$this
->
rawCCPHIDs
);
$body
=
$mail
->
getBody
();
$body
.=
"
\n
"
;
$body
.=
$this
->
getRecipientsSummary
(
$to_handles
,
$cc_handles
);
$mail
->
setBody
(
$body
);
$html_body
=
$mail
->
getHTMLBody
();
if
(
strlen
(
$html_body
))
{
$html_body
.=
hsprintf
(
'%s'
,
$this
->
getRecipientsSummaryHTML
(
$to_handles
,
$cc_handles
));
}
$mail
->
setHTMLBody
(
$html_body
);
$reply_to
=
$this
->
getReplyTo
();
if
(
$reply_to
)
{
$mail
->
setReplyTo
(
$reply_to
);
}
$to
=
array_keys
(
$this
->
getToMap
());
if
(
$to
)
{
$mail
->
addTos
(
$to
);
}
$cc
=
array_keys
(
$this
->
getCCMap
());
if
(
$cc
)
{
$mail
->
addCCs
(
$cc
);
}
return
$mail
->
save
();
}
private
function
getRecipientsSummary
(
PhabricatorHandleList
$to_handles
,
PhabricatorHandleList
$cc_handles
)
{
if
(!
PhabricatorEnv
::
getEnvConfig
(
'metamta.recipients.show-hints'
))
{
return
''
;
}
$to_handles
=
iterator_to_array
(
$to_handles
);
$cc_handles
=
iterator_to_array
(
$cc_handles
);
$body
=
''
;
if
(
$to_handles
)
{
$body
.=
"To: "
.
implode
(
', '
,
mpull
(
$to_handles
,
'getName'
)).
"
\n
"
;
}
if
(
$cc_handles
)
{
$body
.=
"Cc: "
.
implode
(
', '
,
mpull
(
$cc_handles
,
'getName'
)).
"
\n
"
;
}
return
$body
;
}
private
function
getRecipientsSummaryHTML
(
PhabricatorHandleList
$to_handles
,
PhabricatorHandleList
$cc_handles
)
{
if
(!
PhabricatorEnv
::
getEnvConfig
(
'metamta.recipients.show-hints'
))
{
return
''
;
}
$to_handles
=
iterator_to_array
(
$to_handles
);
$cc_handles
=
iterator_to_array
(
$cc_handles
);
$body
=
array
();
if
(
$to_handles
)
{
$body
[]
=
phutil_tag
(
'strong'
,
array
(),
'To: '
);
$body
[]
=
phutil_implode_html
(
', '
,
mpull
(
$to_handles
,
'getName'
));
$body
[]
=
phutil_tag
(
'br'
);
}
if
(
$cc_handles
)
{
$body
[]
=
phutil_tag
(
'strong'
,
array
(),
'Cc: '
);
$body
[]
=
phutil_implode_html
(
', '
,
mpull
(
$cc_handles
,
'getName'
));
$body
[]
=
phutil_tag
(
'br'
);
}
return
phutil_tag
(
'div'
,
array
(),
$body
);
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Wed, May 7, 9:44 AM (1 d, 20 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
87410
Default Alt Text
PhabricatorMailTarget.php (3 KB)
Attached To
Mode
rP Phorge
Attached
Detach File
Event Timeline
Log In to Comment