本文整理汇总了PHP中Email::SetRecipientFrom方法的典型用法代码示例。如果您正苦于以下问题:PHP Email::SetRecipientFrom方法的具体用法?PHP Email::SetRecipientFrom怎么用?PHP Email::SetRecipientFrom使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Email
的用法示例。
在下文中一共展示了Email::SetRecipientFrom方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: UnSerializeV2
/**
* Custom de-serialization method
* @param string $sSerializedMessage The serialized representation of the message
*/
public static function UnSerializeV2($sSerializedMessage)
{
$aData = unserialize($sSerializedMessage);
$oMessage = new Email();
if (array_key_exists('body', $aData)) {
$oMessage->SetBody($aData['body']['body'], $aData['body']['mimeType']);
}
if (array_key_exists('message_id', $aData)) {
$oMessage->SetMessageId($aData['message_id']);
}
if (array_key_exists('bcc', $aData)) {
$oMessage->SetRecipientBCC($aData['bcc']);
}
if (array_key_exists('cc', $aData)) {
$oMessage->SetRecipientCC($aData['cc']);
}
if (array_key_exists('from', $aData)) {
$oMessage->SetRecipientFrom($aData['from']['address'], $aData['from']['label']);
}
if (array_key_exists('reply_to', $aData)) {
$oMessage->SetRecipientReplyTo($aData['reply_to']);
}
if (array_key_exists('to', $aData)) {
$oMessage->SetRecipientTO($aData['to']);
}
if (array_key_exists('subject', $aData)) {
$oMessage->SetSubject($aData['subject']);
}
if (array_key_exists('headers', $aData)) {
foreach ($aData['headers'] as $sKey => $sValue) {
$oMessage->AddToHeader($sKey, $sValue);
}
}
if (array_key_exists('parts', $aData)) {
foreach ($aData['parts'] as $aPart) {
$oMessage->AddPart($aPart['text'], $aPart['mimeType']);
}
}
if (array_key_exists('attachments', $aData)) {
foreach ($aData['attachments'] as $aAttachment) {
$oMessage->AddAttachment(base64_decode($aAttachment['data']), $aAttachment['filename'], $aAttachment['mimeType']);
}
}
return $oMessage;
}
示例2: ForgotPwdGo
protected function ForgotPwdGo()
{
$sAuthUser = utils::ReadParam('auth_user', '', true, 'raw_data');
try {
UserRights::Login($sAuthUser);
// Set the user's language (if possible!)
$oUser = UserRights::GetUserObject();
if ($oUser == null) {
throw new Exception(Dict::Format('UI:ResetPwd-Error-WrongLogin', $sAuthUser));
}
if (!MetaModel::IsValidAttCode(get_class($oUser), 'reset_pwd_token')) {
throw new Exception(Dict::S('UI:ResetPwd-Error-NotPossible'));
}
if (!$oUser->CanChangePassword()) {
throw new Exception(Dict::S('UI:ResetPwd-Error-FixedPwd'));
}
$sTo = $oUser->GetResetPasswordEmail();
// throws Exceptions if not allowed
if ($sTo == '') {
throw new Exception(Dict::S('UI:ResetPwd-Error-NoEmail'));
}
// This token allows the user to change the password without knowing the previous one
$sToken = substr(md5(APPROOT . uniqid()), 0, 16);
$oUser->Set('reset_pwd_token', $sToken);
CMDBObject::SetTrackInfo('Reset password');
$oUser->DBUpdate();
$oEmail = new Email();
$oEmail->SetRecipientTO($sTo);
$sFrom = MetaModel::GetConfig()->Get('forgot_password_from');
if ($sFrom == '') {
$sFrom = $sTo;
}
$oEmail->SetRecipientFrom($sFrom);
$oEmail->SetSubject(Dict::S('UI:ResetPwd-EmailSubject'));
$sResetUrl = utils::GetAbsoluteUrlAppRoot() . 'pages/UI.php?loginop=reset_pwd&auth_user=' . urlencode($oUser->Get('login')) . '&token=' . urlencode($sToken);
$oEmail->SetBody(Dict::Format('UI:ResetPwd-EmailBody', $sResetUrl));
$iRes = $oEmail->Send($aIssues, true);
switch ($iRes) {
//case EMAIL_SEND_PENDING:
case EMAIL_SEND_OK:
break;
case EMAIL_SEND_ERROR:
default:
IssueLog::Error('Failed to send the email with the NEW password for ' . $oUser->Get('friendlyname') . ': ' . implode(', ', $aIssues));
throw new Exception(Dict::S('UI:ResetPwd-Error-Send'));
}
$this->DisplayLoginHeader();
$this->add("<div id=\"login\">\n");
$this->add("<h1>" . Dict::S('UI:Login:ForgotPwdForm') . "</h1>\n");
$this->add("<p>" . Dict::S('UI:ResetPwd-EmailSent') . "</p>");
$this->add("<form method=\"post\">\n");
$this->add("<table>\n");
$this->add("<tr><td colspan=\"2\" class=\"center v-spacer\"><input type=\"button\" onClick=\"window.close();\" value=\"" . Dict::S('UI:Button:Done') . "\" /></td></tr>\n");
$this->add("</table>\n");
$this->add("</form>\n");
$this->add("</div\n");
} catch (Exception $e) {
$this->DisplayForgotPwdForm(true, $e->getMessage());
}
}
示例3: SendNotification
public function SendNotification($sSubject, $sBody)
{
$iContact = $this->Get('notify_contact_id');
if ($iContact == 0) {
// Leave silently...
return;
}
$oContact = MetaModel::GetObject('Contact', $iContact);
// Determine the email attribute (the first one will be our choice)
$sEmailAttCode = null;
foreach (MetaModel::ListAttributeDefs(get_class($oContact)) as $sAttCode => $oAttDef) {
if ($oAttDef instanceof AttributeEmailAddress) {
$sEmailAttCode = $sAttCode;
// we've got one, exit the loop
break;
}
}
if (is_null($sEmailAttCode)) {
// Leave silently...
return;
}
$sTo = $oContact->Get($sEmailAttCode);
$sFrom = $sTo;
$sBody = '<p>Data synchronization: ' . $this->GetHyperlink() . '</p>' . $sBody;
$sSubject = 'iTop Data Sync - ' . $this->GetName() . ' - ' . $sSubject;
$oEmail = new Email();
$oEmail->SetRecipientTO($sTo);
$oEmail->SetRecipientFrom($sFrom);
$oEmail->SetSubject($sSubject);
$oEmail->SetBody($sBody);
if ($oEmail->Send($aIssues) == EMAIL_SEND_ERROR) {
// mmmm, what can I do?
}
}
示例4: DisplayStep2
/**
* Display the form for the second step of the configuration wizard
* which consists in sending an email, which maybe a problem under Windows
*/
function DisplayStep2(SetupPage $oP, $sFrom, $sTo)
{
//$sNextOperation = 'step3';
$oP->add("<h1>iTop configuration wizard</h1>\n");
$oP->add("<h2>Step 2: send an email</h2>\n");
$oP->add("<p>Sending an email to '{$sTo}'... (From: '{$sFrom}')</p>\n");
$oP->add("<form method=\"post\">\n");
$oEmail = new Email();
$oEmail->SetRecipientTO($sTo);
$oEmail->SetRecipientFrom($sFrom);
$oEmail->SetSubject("Test iTop");
$oEmail->SetBody("<p>Hello,</p><p>The email function is now working fine.</p><p>You may now be able to use the notification function.</p><p>iTop</p>");
$iRes = $oEmail->Send($aIssues, true);
switch ($iRes) {
case EMAIL_SEND_OK:
$sTransport = MetaModel::GetConfig()->Get('email_transport');
if ($sTransport == 'LogFile') {
$oP->ok("The email has been logged into the file " . APPROOT . "/log/mail.log.");
} else {
$oP->ok("The email has been sent, check your inbox for the incoming mail...");
}
$oP->add("<button onClick=\"window.history.back();\"><< Back</button>\n");
break;
case EMAIL_SEND_PENDING:
$oP->ok("Email queued");
$oP->add("<button onClick=\"window.history.back();\"><< Back</button>\n");
break;
case EMAIL_SEND_ERROR:
foreach ($aIssues as $sError) {
$oP->error($sError);
}
$oP->add("<button onClick=\"window.history.back();\"><< Back</button>\n");
break;
}
}
示例5: DoExecute
protected function DoExecute()
{
for ($i = 0; $i < 2; $i++) {
$oMail = new Email();
$oMail->SetRecipientTO('romain.quetiez@combodo.com');
$oMail->SetRecipientFrom('romain.quetiez@combodo.com');
$oMail->SetRecipientCC('romainquetiez@yahoo.fr');
$oMail->SetSubject('automated test - ' . $i);
$oMail->SetBody('this is one is entirely working fine ' . time());
$iRes = $oMail->Send($aIssues, false);
switch ($iRes) {
case EMAIL_SEND_OK:
echo "EMAIL_SEND_OK<br/>\n";
break;
case EMAIL_SEND_PENDING:
echo "EMAIL_SEND_PENDING<br/>\n";
break;
case EMAIL_SEND_ERROR:
echo "EMAIL_SEND_ERROR: <br/>\n";
foreach ($aIssues as $sIssue) {
echo "Issue: {$sIssue}<br/>\n";
}
break;
}
}
}
示例6: DisplayStep2
/**
* Display the form for the second step of the configuration wizard
* which consists in sending an email, which maybe a problem under Windows
*/
function DisplayStep2(SetupPage $oP, $sFrom, $sTo)
{
//$sNextOperation = 'step3';
$oP->add("<h1>iTop configuration wizard</h1>\n");
$oP->add("<h2>Step 2: send an email</h2>\n");
$oP->add("<p>Sending an email to '{$sTo}'... (From: '{$sFrom}')</p>\n");
$oP->add("<form method=\"post\">\n");
$oEmail = new Email();
$oEmail->SetRecipientTO($sTo);
$oEmail->SetRecipientFrom($sFrom);
$oEmail->SetSubject("Test iTop");
$oEmail->SetBody("<p>Hello,</p><p>The email function is now working fine.</p><p>You may now be able to use the notification function.</p><p>iTop</p>");
$iRes = $oEmail->Send($aIssues, true);
switch ($iRes) {
case EMAIL_SEND_OK:
$oP->ok("The email has been sent, you may now check that the email will arrive...");
break;
case EMAIL_SEND_PENDING:
$oP->ok("Email queued");
$oP->add("<button onClick=\"window.history.back();\"><< Back</button>\n");
break;
case EMAIL_SEND_ERROR:
foreach ($aIssues as $sError) {
$oP->error($sError);
}
$oP->add("<button onClick=\"window.history.back();\"><< Back</button>\n");
break;
}
}