本文整理汇总了PHP中PHPMailer::setFrom方法的典型用法代码示例。如果您正苦于以下问题:PHP PHPMailer::setFrom方法的具体用法?PHP PHPMailer::setFrom怎么用?PHP PHPMailer::setFrom使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PHPMailer
的用法示例。
在下文中一共展示了PHPMailer::setFrom方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: send
function send()
{
$conf = $this->smtp;
$mail = new PHPMailer();
$mail->IsSMTP(false);
//$mail->Host = $conf['host'];
//$mail->SMTPAuth = true;
$mail->IsHTML(true);
//$mail->SMTPDebug = 2;
//$mail->Port = $conf['port'];
//$mail->Username = $conf['user'];
//$mail->Password = $conf['pass'];
//$mail->SMTPSecure = 'tls';
$mail->setFrom($this->from, 'Onboarding Mail');
$mail->addReplyTo($this->from, 'Onboarding Mail');
$mail->addAddress($this->to);
foreach ($this->attachment as $k => $att) {
$num = $k + 1;
$fname = "Events{$num}_" . date('h:i:s') . ".ics";
$mail->AddStringAttachment($att, $fname, 'base64', 'text/ics');
}
$mail->Subject = $this->subject;
$mail->Body = $this->bodyText;
if (!$mail->send()) {
echo '<pre>';
echo 'Message could not be sent.<br>';
echo 'Mailer Error: ' . $mail->ErrorInfo;
exit;
}
}
示例2: populateMessage
/**
* Populate the email message
*/
private function populateMessage()
{
$attributes = $this->attributes;
$this->mailer->CharSet = 'UTF-8';
$this->mailer->Subject = $attributes['subject'];
$from_parts = Email::explodeEmailString($attributes['from']);
$this->mailer->setFrom($from_parts['email'], $from_parts['name']);
$to = Helper::ensureArray($this->attributes['to']);
foreach ($to as $to_addr) {
$to_parts = Email::explodeEmailString($to_addr);
$this->mailer->addAddress($to_parts['email'], $to_parts['name']);
}
if (isset($attributes['cc'])) {
$cc = Helper::ensureArray($attributes['cc']);
foreach ($cc as $cc_addr) {
$cc_parts = Email::explodeEmailString($cc_addr);
$this->mailer->addCC($cc_parts['email'], $cc_parts['name']);
}
}
if (isset($attributes['bcc'])) {
$bcc = Helper::ensureArray($attributes['bcc']);
foreach ($bcc as $bcc_addr) {
$bcc_parts = Email::explodeEmailString($bcc_addr);
$this->mailer->addBCC($bcc_parts['email'], $bcc_parts['name']);
}
}
if (isset($attributes['html'])) {
$this->mailer->msgHTML($attributes['html']);
if (isset($attributes['text'])) {
$this->mailer->AltBody = $attributes['text'];
}
} elseif (isset($attributes['text'])) {
$this->mailer->msgHTML($attributes['text']);
}
}
示例3: send
/**
* Send email
* @param array $to
* @param array $from
* @param string $subject
* @param string $text
* @param bool $use_template
* @return bool
*/
public function send($to, $from, $subject, $text, $use_template = true)
{
$this->client->setFrom($from[1], $from[0]);
$this->client->addAddress($to[1], $to[0]);
$this->client->Subject = $subject;
if ($use_template) {
$template = '
<!DOCTYPE HTML>
<html dir="rtl">
<head>
<meta charset="utf-8">
</head>
<body style="font-family: tahoma, sans-serif !important;">
<div style="font: 13px tahoma,sans-serif !important;direction: rtl;background-color: #e8e8e8;">
<div style="width: 70%;background-color: #fff;background-color: #fff; border-radius: 3px;margin: auto;position: relative;border-left: 1px solid #d9d9d9;border-right: 1px solid #d9d9d9;">
<div style="top: 0;position: absolute;width: 100%; height: 4px;background: url( \'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACgAAAAECAYAAAD8kH0gAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAGhJREFUeNpi/P///xkGKFh27TfDkiu/GQiBKC1WhhgdVoLqXkzsZHje30ZQnUR+OYNkYRVWORZkxy0DOo6JgGERpDhuYgcDAxN+EyVyS3E6DgSYkB3HQG3HEQo5Ao4DO3AwOw4EAAIMAMZJM9nl1EbWAAAAAElFTkSuQmCC\' ) repeat;"></div>
<div style="padding: 22px 15px;">
{TEXT}
</div>
<div style="bottom: 0;position: absolute;width: 100%; height: 4px;background: url( \'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACgAAAAECAYAAAD8kH0gAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAGhJREFUeNpi/P///xkGKFh27TfDkiu/GQiBKC1WhhgdVoLqXkzsZHje30ZQnUR+OYNkYRVWORZkxy0DOo6JgGERpDhuYgcDAxN+EyVyS3E6DgSYkB3HQG3HEQo5Ao4DO3AwOw4EAAIMAMZJM9nl1EbWAAAAAElFTkSuQmCC\' ) repeat;"></div>
</div>
</div>
</body>
</html>
';
$msg = str_replace('{TEXT}', $text, $template);
} else {
$msg = $text;
}
$this->client->msgHTML($msg);
return $this->client->send();
}
示例4: __construct
/**
* ### Sets the basic PHPMailer settings and content
*
* Mail constructor.
* @param array $to
* @param string $subject
* @param string $content
*/
public function __construct($to = [], $subject = '', $content = '')
{
$this->mailer = new \PHPMailer();
$this->protocol(Config::get('mail', 'protocol'));
$this->mailer->Host = Config::get('mail', 'host');
$this->mailer->Port = Config::get('mail', 'port');
$this->mailer->Username = Config::get('mail', 'username');
$this->mailer->Password = Config::get('mail', 'password');
$this->mailer->SMTPSecure = Config::get('mail', 'encryption');
$this->mailer->setFrom(Config::get('mail', 'from')[0], Config::get('mail', 'from')[1]);
$this->mailer->addAddress($to[0], $to[1]);
$this->mailer->isHTML(true);
$this->mailer->Subject = $subject;
$this->mailer->Body = $content;
}
示例5: dispararEmail
public function dispararEmail($template_email_id = 0, $user = array(), $extra_data = array())
{
$mail = new \PHPMailer();
$template_emails = TableRegistry::get("TemplateEmails");
$template_email = $template_emails->get($template_email_id);
$html = $template_email->content;
$html = str_replace('{{user}}', $user->full_name, $html);
$html = str_replace('{{password}}', @$extra_data['new_password'], $html);
$html = str_replace('{{current_password}}', @$extra_data['current_password'], $html);
foreach ($extra_data as $key => $val) {
$html = str_replace('{{' . $key . '}}', $val, $html);
}
$mail->isSMTP();
// Set mailer to use SMTP
$mail->Host = 'mail.smtp2go.com';
// Specify main and backup SMTP servers
$mail->SMTPAuth = true;
// Enable SMTP authentication
$mail->Username = 'contato@0e1dev.com';
// SMTP username
$mail->Password = 'relogio123';
// SMTP password
// $mail->SMTPSecure = 'tls'; // Enable TLS encryption, `ssl` also accepted
$mail->Port = 2525;
// TCP port to connect to
$mail->setFrom('pedro@pep.net.br', 'Pedro Sampaio');
$mail->addAddress($user->username);
// Name is optional
$mail->isHTML(true);
// Set email format to HTML
$mail->Subject = '[PEP] ' . $template_email->title;
$mail->Body = $html;
$mail->AltBody = $html;
return $mail->send();
}
示例6: onLoad
public function onLoad($param)
{
parent::onLoad($param);
$checkNewsletter = nNewsletterRecord::finder()->findByStatus(1);
if ($checkNewsletter) {
$layout = nLayoutRecord::finder()->findBy_nNewsletterID($checkNewsletter->ID);
$mail = new PHPMailer();
$mail->isSendmail();
$mail->setFrom('from@vp.d2.pl', 'First Last');
$mail->addReplyTo('from@vp.d2.pl');
$lista = nSenderRecord::finder()->findAll('nLayoutID = ? AND Status = 0 LIMIT 25', $layout->ID);
foreach ($lista as $person) {
$mail->addAddress($person->Email);
$mail->Subject = $checkNewsletter->Name;
$mail->msgHTML($layout->HtmlText);
if ($mail->send()) {
$person->Status = 1;
$person->save();
} else {
$person->Status = 5;
$person->save();
echo "Mailer Error: " . $mail->ErrorInfo;
}
}
if (empty($lista)) {
$checkNewsletter->Status = 0;
$checkNewsletter->save();
}
}
die;
}
示例7: init
public static function init()
{
$mail = new PHPMailer();
//Tell PHPMailer to use SMTP
$mail->isSMTP();
//Enable SMTP debugging
// 0 = off (for production use)
// 1 = client messages
// 2 = client and server messages
$mail->SMTPDebug = 0;
//Ask for HTML-friendly debug output
$mail->Debugoutput = 'html';
//Set the hostname of the mail server
$mail->Host = FRELAY_SMTP;
$mail->SMTPSecure = "tls";
//Set the SMTP port number - likely to be 25, 465 or 587
$mail->Port = FSMTP_PORT;
//Whether to use SMTP authentication
$mail->SMTPAuth = true;
$mail->Username = FSMTP_USER;
$mail->Password = FSMTP_PASS;
//Set who the message is to be sent from
$mail->setFrom(FSMTP_FROM, FSMTP_FROM_NAME);
self::$obMailer = $mail;
}
示例8: processMail
function processMail($from, $to, $subject, $messageBody, $messageBodyTxt)
{
$mail = new PHPMailer();
$mail->SMTPDebug = false;
// Enable verbose debug output
$mail->CharSet = "UTF-8";
$mail->isSMTP();
// Set mailer to use SMTP
$mail->Host = 'mail.speedpartner.de';
// Specify main and backup SMTP servers
$mail->SMTPAuth = true;
// Enable SMTP authentication
$mail->Username = 'campaign@bilandia.de';
// SMTP username
$mail->Password = 'ein1328_prosit_2016';
// SMTP password
$mail->SMTPSecure = 'tls';
// Enable TLS encryption, `ssl` also accepted
$mail->Port = 25;
// TCP port to connect to
$mail->setFrom($from, 'Mailer');
$mail->addAddress($to);
// Add a recipient
$mail->addReplyTo($from);
$mail->isHTML(true);
// Set email format to HTML
$mail->Subject = $subject;
$mail->Body = $messageBody;
if (strlen(trim($messageBodyTxt)) > 0) {
$mail->AltBody = $messageBodyTxt;
}
if (!$mail->send()) {
$sendingResults = "{\"result\" : \"error\",\"message\" : \"Message could not be sent\", \"PHPMailerMsg\" : \"" . $mail->ErrorInfo . "\"}";
}
}
示例9: sendMail
function sendMail($mail, $message)
{
$mail = new PHPMailer();
//$mail->SMTPDebug = 2; // Enable verbose debug output
$mail->isSMTP();
// Set mailer to use SMTP
$mail->Host = 'smtp.gmail.com';
// Specify main and backup SMTP servers
$mail->SMTPAuth = true;
// Enable SMTP authentication
$mail->Username = 'no.reply.molpe@gmail.com';
// SMTP username
$mail->Password = '0258794613';
// SMTP password
$mail->SMTPSecure = 'tls';
// Enable TLS encryption, `ssl` also accepted
$mail->Port = 587;
// TCP port to connect to
$mail->setFrom('no.reply.molpe@gmail.com', 'Mailer');
$mail->addAddress('$mail');
// Add a recipient
$mail->isHTML(false);
// Set email format to HTML
$mail->Subject = 'Bienvenue sur Molpe !';
$mail->Body = '$message';
/*if(!$mail->send()) {
echo 'Message could not be sent.';
echo 'Mailer Error: ' . $mail->ErrorInfo;
} else {
//echo 'Message has been sent';
}*/
}
示例10: sendEmail
function sendEmail($force, $clients, $subject, $body, $resources = array())
{
$mail = new PHPMailer();
$mail->isSMTP();
$mail->Host = SMTP_HOST;
$mail->SMTPAuth = true;
$mail->Username = EMAIL;
$mail->Password = PASSWORD;
$mail->SMTPSecure = SMTP_SECURE;
$mail->Port = SMTP_PORT;
$mail->setFrom(EMAIL, 'The cat long');
$mail->isHTML(true);
$mail->Subject = $subject;
foreach ($clients as $client) {
if (EMAIL != $client['email'] && !empty($client['news']) || !!$force) {
$mail->addAddress($client['email']);
}
}
$mail->Body = $body;
foreach ($resources as $i) {
if (!isset($i['absolute'])) {
$mail->addAttachment(IMGS . $i['path']);
} else {
$mail->addAttachment($i['path']);
}
}
$mail->AltBody = $body;
if ($mail->send()) {
flash('msg', 'Su email se ha enviado correctamente', 'Notificación');
return header('location: /');
}
}
示例11: configureMailer
public function configureMailer()
{
$mail = new \PHPMailer();
// $mail->SMTPDebug = 3; // Enable verbose debug output
$mail->isSMTP();
// Set mailer to use SMTP
$mail->Host = getenv('EMAIL_SMTP');
// Specify main and backup SMTP servers
$mail->SMTPAuth = true;
// Enable SMTP authentication
$mail->Username = getenv('EMAIL_FROM');
// SMTP username
$mail->Password = getenv('EMAIL_FROM_PASSWORD');
// SMTP password
$mail->SMTPSecure = getenv('EMAIL_SMTP_SECURITY');
// Enable TLS encryption, `ssl` also accepted
$mail->Port = getenv('EMAIL_SMTP_PORT');
// TCP port to connect to
//From myself to myself (alter reply address)
$mail->setFrom(getenv('EMAIL_FROM'), getenv('EMAIL_FROM_NAME'));
$mail->addAddress(getenv('EMAIL_TO'), getenv('EMAIL_TO_NAME'));
$mail->isHTML(true);
// Set email format to HTML
return $mail;
}
示例12: gogo
public function gogo($email)
{
$mail = new PHPMailer();
$mail->isSMTP();
// Set mailer to use SMTP
$mail->Host = 'mail.your-server.de';
// Specify main and backup server
$mail->SMTPAuth = true;
// Enable SMTP authentication
$mail->Username = 'no-reply@matchday.biz';
// SMTP username
$mail->Password = '11zRyyWMel79g2fO';
// SMTP password
$mail->SMTPSecure = 'tls';
// Enable encryption, 'ssl' also accepted
$mail->Port = 25;
//Set the SMTP port number - 587 for authenticated TLS
$mail->setFrom('no-reply@matchday.biz', 'Matchday');
//Set who the message is to be sent from
$mail->addAddress($email);
// Add a recipient
$mail->isHTML(true);
// Set email format to HTML
$mail->CharSet = 'UTF-8';
$text = "Информация по инциденту 22.01.2016";
$text = iconv(mb_detect_encoding($text, mb_detect_order(), true), "UTF-8", $text);
$mail->Subject = $text;
$mail->Body = "Уважаемые пользователи ресурса matchday.biz! <br/><br/>\n\t\t\n\t\tБез всякого предупреждения нас отключили от хостинга. Хостер (немецкая компания hetzner.de) обнаружил перегрузку сервера, связанную с многочисленными запросами, идущими на наш сайт со стороннего адреса и отключил нас, отказавшись далее разбираться до понедельника.\n\t\tНаши специалисты диагностировали проблему и выяснили, что запросы идут с пула IP адресов ТОГО ЖЕ хостера – то есть, от него самого, что свидетельствует о том, что у хостера просто некорректно налажена работа самого хостинга.\n\t\tТехподдержка с нами отказалась работать после 18-00 пятницы немецкого времени, и сайт matchday.biz будет теперь гарантировано лежать до середины дня понедельника, 25 января.\n\t\t(желающие прочитать про очень похожий случай с этим же хостером могут сделать это тут).<br/><br/>\n\t\t\n\t\tНезависимо от того, чем закончится эта история, мы будем менять хостера, но локальная задача – включить сайт, чем мы и будем заниматься, увы, теперь только в понедельник.\n\t\tМы очень извиняемся за неудобства, причиненные этой историей, которая полностью находится вне нашего контроля.<br/><br/>\n\t\t\n\t\tПодкаст по итогам 23го тура будет записан авторами в воскресение и будет опубликован, как только сайт станет доступным.\n\t\tНи бетмен-лайв, ни фэнтэзи-лайв в23м туре провести не представляется возможным.<br/>\n\t\tВ бетмене все ставки будут засчитаны.<br/><br/>\n\t\t\n\t\tО доступности сайта мы немедленно вас проинформируем, в том числе и на сайте arsenal-blog.com.<br/><br/>\n\t\t\n\t\t\n\t\tАдминистрация matchday.biz";
if (!$mail->send()) {
return false;
}
return true;
}
示例13: send
public static function send($to_email, $reply_email, $reply_name, $from_email, $from_name, $subject, $body, $attachments = array())
{
if (Configuration::model()->emailer->relay == 'SMTP') {
$email = new \PHPMailer();
//$email->SMTPDebug = 4;
$email->isSMTP();
$email->Host = Configuration::model()->emailer->host;
$email->SMTPAuth = Configuration::model()->emailer->auth;
$email->Username = Configuration::model()->emailer->username;
$email->Password = Configuration::model()->emailer->password;
$email->SMTPSecure = Configuration::model()->emailer->security;
$email->Port = Configuration::model()->emailer->port;
}
$email->addAddress($to_email);
$email->addReplyTo($reply_email, $reply_name);
$email->setFrom($from_email, $from_name);
$email->Subject = $subject;
$email->Body = $body;
$email->msgHTML($body);
$email->AltBody = strip_tags(str_replace('<br>', "\n\r", $body));
if (is_array($attachments)) {
foreach ($attachments as $value) {
$email->addAttachment($value);
}
}
$email->send();
}
示例14: send
/**
* Send an email
*
* @param string $name Name
* @param string $email Email address
* @param string $subject Subject
* @param string $body Body
* @return boolean true if the email was sent successfully, false otherwise
*/
public static function send($name, $email, $subject, $body)
{
require dirname(dirname(__FILE__)) . '/vendors/PHPMailer/PHPMailerAutoload.php';
$mail = new PHPMailer();
//Set PHPMailer to use SMTP.
$mail->isSendMail();
//Set SMTP host name
$mail->Host = Config::SMTP_HOST;
//Set this to true if SMTP host requires authentication to send email
$mail->SMTPAuth = true;
//Provide username and password
$mail->Username = Config::SMTP_USER;
$mail->Password = Config::SMTP_PASS;
//If SMTP requires TLS encryption then set it
$mail->SMTPSecure = Config::SMTP_CERTIFICATE;
//Set TCP port to connect to
$mail->Port = Config::SMTP_PORT;
$mail->setFrom($email, $name);
$mail->addAddress(Config::SMTP_USER, Config::SMTP_NAME);
$mail->isHTML(true);
$mail->Subject = $subject;
$mail->Body = $body;
if (!$mail->send()) {
echo 'Message could not be sent.';
echo 'Mailer Error: ' . $mail->ErrorInfo;
}
}
示例15: EnviarCorreo
public function EnviarCorreo(CorreosDTO $dto)
{
$mail = new PHPMailer();
$mail->isSMTP();
//Correo del remitente
$mail->Host = 'smtp.gmail.com';
$mail->SMTPAuth = true;
$mail->Username = $dto->getRemitente();
$mail->Password = $dto->getContrasena();
$mail->SMTPSecure = 'tls';
$mail->Port = 587;
$mail->CharSet = 'UTF-8';
$mail->setFrom($dto->getRemitente(), $dto->getNombreRemitente());
//Correo del destinatario
$mail->addAddress($dto->getDestinatario());
$mail->addReplyTo($dto->getRemitente(), $dto->getNombreRemitente());
$mail->addAttachment($dto->getArchivos());
//Adjuntar Archivos
$mail->isHTML(true);
$mail->Subject = $dto->getAsunto();
//Cuerpo del correo
$mail->Body = $dto->getContenido();
if (!$mail->send()) {
$mensaje2 = 'No se pudo enviar el correo ' . 'Error: ' . $mail->ErrorInfo;
} else {
$mensaje2 = 'True';
}
return $mensaje2;
}