本文整理汇总了PHP中Zend\Mail\Message::addFrom方法的典型用法代码示例。如果您正苦于以下问题:PHP Message::addFrom方法的具体用法?PHP Message::addFrom怎么用?PHP Message::addFrom使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend\Mail\Message
的用法示例。
在下文中一共展示了Message::addFrom方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: sendContactMail
/**
* Send contact mail
* @param $controller
* @param $data
*/
public static function sendContactMail($controller, $data)
{
// prepare html content
$comments = nl2br($data['comments']);
// line break
$content = '';
$content .= '<table>';
$content .= '<tbody>';
$content .= "<tr><td>First Name:</td><td>{$data['firstName']}</td></tr>";
$content .= "<tr><td>Last Name:</td><td>{$data['lastName']}</td></tr>";
$content .= "<tr><td>Phone Number:</td><td>{$data['phone']}</td></tr>";
$content .= "<tr><td>Email:</td><td>{$data['email']}</td></tr>";
$content .= "<tr><td>Company:</td><td>{$data['company']}</td></tr>";
$content .= "<tr><td>Job Title:</td><td>{$data['jobTitle']}</td></tr>";
$content .= "<tr><td>Comments:</td><td>{$comments}</td></tr>";
$content .= '</tbody>';
$content .= '</table>';
$html = new MimePart($content);
$html->type = "text/html";
$body = new MimeMessage();
$body->setParts(array($html));
$message = new Message();
$message->setBody($body);
// subject
$subject = 'Contact from Papertask';
$message->setSubject($subject);
// get transport
$transport = $controller->getServiceLocator()->get('mail.transport');
$message->addTo($transport->mailOptions['contact']);
$message->addFrom($transport->mailOptions['contact']);
$transport->send($message);
}
示例2: add
/**
* @param string $queue_name
* @param \Zend\Mail\Message $mail
*/
public function add($queue_name, \Zend\Mail\Message $message)
{
if (!count($message->getFrom())) {
$message->addFrom($this->config['default_from']);
}
$this->table->add($queue_name, $message);
}
示例3: sendMail
/**
* @param string $subject
* @param string $message
* @param null|string|array $to
* @param null|string|array $cc
* @param null|string|array $bcc
* @return array
*/
public function sendMail($subject, $message, $to = null, $cc = null, $bcc = null)
{
$return = array('success' => true, 'msg' => null);
$partBody = new MimePart($this->getPartHeader() . $message . $this->getPartFooter());
$partBody->type = Mime::TYPE_HTML;
$partBody->charset = 'utf-8';
$this->body->setParts(array($partBody));
$subject = '[' . APPLICATION_NAME . '] ' . $subject;
$mail = new Message();
$mail->addFrom(self::FROM);
$mail->setSubject($subject);
$mail->setBody($this->body);
$mail->setTo($to);
if ($cc) {
$mail->setCc($cc);
}
if ($bcc) {
$mail->setBcc($bcc);
}
try {
$this->transport->send($mail);
} catch (\Exception $e) {
$return['success'] = false;
$return['msg'] = _('mail.message.not_sent');
//throw new \Exception($e->getMessage(), $e->getCode());
}
return $return;
}
示例4: run
public function run()
{
$transport = new SmtpTransport(new SmtpOptions(array('name' => $this->host, 'host' => $this->host, 'port' => $this->port, 'connection_config' => array('username' => $this->sender->getUsername(), 'password' => $this->sender->getPassword()))));
if ($this->auth !== null) {
$transport->getOptions()->setConnectionClass($this->auth);
}
$message = new Message();
$message->addFrom($this->sender->getUsername())->setSubject($this->subject);
if ($this->bcc) {
$message->addBcc($this->recipients);
} else {
$message->addTo($this->recipients);
}
$body = new MimeMessage();
if ($this->htmlBody == null) {
$text = new MimePart($this->textBody);
$text->type = "text/plain";
$body->setParts(array($text));
} else {
$html = new MimePart($this->htmlBody);
$html->type = "text/html";
$body->setParts(array($html));
}
$message->setBody($body);
$transport->send($message);
}
示例5: sendMail
public function sendMail(MailMessage $message)
{
$from = $message->getFrom();
if (count($from) == 0) {
$message->addFrom($this->createSenderAddress());
}
$this->transport->send($message);
}
示例6: assemble
/**
* @param string $to
* @param Template $template
* @param array $data
* @return Message
*/
public function assemble($to, Template $template, array $data)
{
$html = new MimePart($template->getBody($data));
$html->type = "text/html";
$body = new MimeMessage();
$body->addPart($html);
$message = new Message();
$message->addFrom($this->config['from-email'], $this->config['from-name'])->addTo($to)->setSubject($template->getSubject())->setBody($body)->setEncoding("UTF-8");
return $message;
}
示例7: testRestoreFromSerializedString
public function testRestoreFromSerializedString()
{
$this->message->addTo('zf-devteam@example.com', 'ZF DevTeam');
$this->message->addFrom('matthew@example.com', "Matthew Weier O'Phinney");
$this->message->addCc('zf-contributors@example.com', 'ZF Contributors List');
$this->message->setSubject('This is a subject');
$this->message->setBody('foo');
$serialized = $this->message->toString();
$restoredMessage = Message::fromString($serialized);
$this->assertEquals($serialized, $restoredMessage->toString());
}
示例8: createMessage
private function createMessage()
{
$message = new Message();
$config = $this->config['message'];
$message->addTo($config['to']);
if ($config['from']) {
$message->addFrom($config['from']);
}
$message->setSender($config['sender']['address'], $config['sender']['name']);
return $message;
}
示例9: sendPasswordLostMail
/**
* Send password lost email.
*
* @param NewUserModel $activation
* @param MemberModel $member
*/
public function sendPasswordLostMail(NewUserModel $newUser, MemberModel $member)
{
$body = $this->render('user/email/reset', ['user' => $newUser, 'member' => $member]);
$translator = $this->getServiceManager()->get('translator');
$message = new Message();
$config = $this->getConfig();
$message->addFrom($config['from']);
$message->addTo($newUser->getEmail());
$message->setSubject($translator->translate('Password reset code for the GEWIS Website'));
$message->setBody($body);
$this->getTransport()->send($message);
}
示例10: sendRegisterEmail
/**
* Send registration email.
*
* @param NewUserModel $newUser
* @param MemberModel $member
*/
public function sendRegisterEmail(NewUserModel $newUser, MemberModel $member)
{
$body = $this->render('user/email/register', array('user' => $newUser, 'member' => $member));
$translator = $this->getServiceManager()->get('translator');
$message = new Message();
$config = $this->getConfig();
$message->addFrom($config['from']);
$message->addTo($newUser->getEmail());
$message->setSubject($translator->translate('Account activation code for the GEWIS Website'));
$message->setBody($body);
$this->getTransport()->send($message);
}
示例11: send
public function send($subject, $messageBody)
{
$html = new \Zend\Mime\Part(nl2br($messageBody));
$html->type = 'text/html';
$body = new \Zend\Mime\Message();
$body->setParts(array($html));
$message = new Message();
$message->addFrom($this->fromAddress, $this->fromName)->addTo($this->toAddress)->setSubject($subject);
$message->setBody($body);
$transport = $this->getTransport();
$transport->send($message);
}
示例12: prepareMail
protected function prepareMail(MailMessage $mail, array $viewVariables, $mailTemplateName)
{
$mailBodyOutput = $this->getRenderContent($viewVariables, $mailTemplateName);
$mailBodyOutput = htmlspecialchars_decode(htmlentities($mailBodyOutput, ENT_NOQUOTES, 'UTF-8', false), ENT_NOQUOTES);
$content = new MimeMessage();
$part = new Part($mailBodyOutput);
$part->type = 'text/html';
$content->addPart($part);
$mail->addFrom($this->mailAddress, $this->senderName);
$this->addMailTargets($mail);
$mail->setEncoding('UTF-8');
$mail->setBody($content);
}
示例13: send
public function send()
{
$smtpOptions = new SmtpOptions(array('name' => 'smtp.gmail.com', 'host' => 'smtp.gmail.com', 'connection_class' => 'login', 'connection_config' => array('username' => 'naman.bakliwal@optimusinfo.com', 'password' => 'optimus@123', 'port' => 465, 'ssl' => 'TLS')));
$html = new MimePart($this->getBody());
$html->type = "text/html";
$body = new MimeMessage();
$body->setParts(array($html));
$mailTransport = new Smtp();
$mailTransport->setOptions($smtpOptions);
$mail = new Message();
$mail->addFrom('naman.bakliwal@optimusinfo.com', 'Travelopod')->setEncoding('utf-8')->setTo($this->getTo())->setSubject($this->getSubject())->setBody($body);
$send = $mailTransport->send($mail);
$mailTransport->disconnect();
}
示例14: contruirCorreo
public function contruirCorreo(array $param = null)
{
$mail = new Mail\Message();
$mail->setTo('jgbpqek@gmail.com', 'Jeisson');
//de
$mail->addFrom('jgb_17@hotmail.com');
//para
$mail->setSubject('Clave ingreso');
//asunto
$cfg = array('ssl' => 'tls', 'username' => 'jgbpqek@gmail.com', 'password' => 'JeissonB_1989');
$smtpOption = new Mail\Transport\SmtpOptions();
$smtpOption->setHost('smtp.gmail.com')->setConnectionClass('login')->setName('smtp.gmail.com')->setConnectionConfig($cfg);
$smtp = new Mail\Transport\Smtp($smtpOption);
$smtp->send($mail);
}
示例15: sendActivityCreationEmail
/**
* Send activity creation email.
*
* @param ActivityModel $activity
*/
public function sendActivityCreationEmail(ActivityModel $activity)
{
$body = $this->render('email/activity', ['activity' => $activity]);
$html = new MimePart($body);
$html->type = "text/html";
$mimeMessage = new MimeMessage();
$mimeMessage->setParts([$html]);
$message = new Message();
$config = $this->getConfig();
$message->addFrom($config['from']);
$message->addTo($config['to']['activity_creation']);
$message->setSubject('Nieuwe activiteit aangemaakt op de GEWIS website | New activity was created on the GEWIS website');
$message->setBody($mimeMessage);
$this->getTransport()->send($message);
}