本文整理汇总了PHP中PHPMailer::SetFrom方法的典型用法代码示例。如果您正苦于以下问题:PHP PHPMailer::SetFrom方法的具体用法?PHP PHPMailer::SetFrom怎么用?PHP PHPMailer::SetFrom使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PHPMailer
的用法示例。
在下文中一共展示了PHPMailer::SetFrom方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: sendMail
public function sendMail($to, $subject, $body, $files = array())
{
$mail = new PHPMailer();
$mail->IsSMTP();
$mail->SMTPDebug = 2;
$mail->SMTPAuth = true;
$mail->SMTPSecure = EMAIL_SMTPSECURE;
$mail->Host = EMAIL_SMTPHOST;
$mail->Port = EMAIL_SMTPPORT;
$mail->Username = EMAIL_SMTPUSER;
$mail->Password = EMAIL_SMTPPASSWORD;
$mail->SetFrom(EMAIL_SENDER, EMAIL_SENDERNAME);
$mail->Subject = $subject;
foreach ($files as $file) {
$mail->AddAttachment($file, basename($file));
}
$mail->MsgHTML($body);
$mail->AddAddress($to);
ob_start();
$ok = $mail->Send();
$ob = ob_get_contents();
ob_end_clean();
if (!$ok) {
$this->error = $mail->ErrorInfo . "\n" . $ob;
$this->processError();
}
}
示例2: __construct
/**
* 构造函数
*
* @access public
* @param string $config['host'] SMTP 服务器
* @param string $config['username']
* @param string $config['password']
* @return void
*/
public function __construct($config)
{
if (file_exists('third_party/phpMailer/class.phpmailer.php') && file_exists('third_party/phpMailer/class.smtp.php')) {
include 'third_party/phpMailer/class.phpmailer.php';
include 'third_party/phpMailer/class.smtp.php';
} else {
throw new Exception('phpMailer lib not found.', 204);
}
$this->host = $config['host'];
$this->userName = $config['username'];
$this->password = $config['password'];
$this->phpMailer = new PHPMailer();
$this->phpMailer->CharSet = $this->charSet;
$this->phpMailer->isSMTP();
$this->phpMailer->SMTPDebug = $this->isDebug;
$this->phpMailer->SMTPAuth = true;
$this->phpMailer->Host = $this->host;
$this->phpMailer->Port = $this->port;
$this->phpMailer->Username = $this->userName;
$this->phpMailer->Password = $this->password;
$this->phpMailer->SetFrom(self::SENDFROMADDRESS, '纳米服务');
$this->phpMailer->Subject = '你有新的通知信息';
$this->phpMailer->AltBody = 'To view the message, please use an HTML compatible email viewer!';
// optional, comment out and test
}
示例3: send
/**
* Short description of method send
*
* @access public
* @author Bertrand Chevrier, <bertrand.chevrier@tudor.lu>
* @return int
*/
public function send()
{
$returnValue = (int) 0;
foreach ($this->messages as $message) {
if ($message instanceof tao_helpers_transfert_Message) {
$this->mailer->SetFrom($message->getFrom());
$this->mailer->AddReplyTo($message->getFrom());
$this->mailer->Subject = $message->getTitle();
$this->mailer->AltBody = strip_tags(preg_replace("/<br.*>/i", "\n", $message->getBody()));
$this->mailer->MsgHTML($message->getBody());
$this->mailer->AddAddress($message->getTo());
try {
if ($this->mailer->Send()) {
$message->setStatus(tao_helpers_transfert_Message::STATUS_SENT);
$returnValue++;
}
if ($this->mailer->IsError()) {
if (DEBUG_MODE) {
echo $this->mailer->ErrorInfo . "<br>";
}
$message->setStatus(tao_helpers_transfert_Message::STATUS_ERROR);
}
} catch (phpmailerException $pe) {
if (DEBUG_MODE) {
print $pe;
}
}
}
$this->mailer->ClearReplyTos();
$this->mailer->ClearAllRecipients();
}
$this->mailer->SmtpClose();
return (int) $returnValue;
}
示例4: phpmail_send
function phpmail_send($from, $to, $subject, $message, $attachment_path = NULL, $cc = NULL, $bcc = NULL)
{
require_once APPPATH . 'modules_core/mailer/helpers/phpmailer/class.phpmailer.php';
$CI =& get_instance();
$mail = new PHPMailer();
$mail->CharSet = 'UTF-8';
$mail->IsHtml();
if ($CI->mdl_mcb_data->setting('email_protocol') == 'smtp') {
$mail->IsSMTP();
$mail->SMTPAuth = true;
if ($CI->mdl_mcb_data->setting('smtp_security')) {
$mail->SMTPSecure = $CI->mdl_mcb_data->setting('smtp_security');
}
$mail->Host = $CI->mdl_mcb_data->setting('smtp_host');
$mail->Port = $CI->mdl_mcb_data->setting('smtp_port');
$mail->Username = $CI->mdl_mcb_data->setting('smtp_user');
$mail->Password = $CI->mdl_mcb_data->setting('smtp_pass');
} elseif ($CI->mdl_mcb_data->setting('email_protocol') == 'sendmail') {
$mail->IsSendmail();
}
if (is_array($from)) {
$mail->SetFrom($from[0], $from[1]);
} else {
$mail->SetFrom($from);
}
$mail->Subject = $subject;
$mail->Body = $message;
$to = strpos($to, ',') ? explode(',', $to) : explode(';', $to);
foreach ($to as $address) {
$mail->AddAddress($address);
}
if ($cc) {
$cc = strpos($cc, ',') ? explode(',', $cc) : explode(';', $cc);
foreach ($cc as $address) {
$mail->AddCC($address);
}
}
if ($bcc) {
$bcc = strpos($bcc, ',') ? explode(',', $bcc) : explode(';', $bcc);
foreach ($bcc as $address) {
$mail->AddBCC($address);
}
}
if ($attachment_path) {
$mail->AddAttachment($attachment_path);
}
if ($mail->Send()) {
if (isset($CI->load->_ci_classes['session'])) {
$CI->session->set_flashdata('custom_success', $CI->lang->line('email_success'));
return TRUE;
}
} else {
if (isset($CI->this->load->_ci_classes['session'])) {
$CI->session->set_flashdata('custom_error', $mail->ErrorInfo);
return FALSE;
}
}
}
示例5: Send
function Send()
{
$mail = new PHPMailer();
$mail->CharSet = 'UTF-8';
$mail->Host = $this->smtp['smtp_server'];
$mail->Port = $this->smtp['smtp_port'];
if ($this->smtp['smtp_enable']) {
$mail->IsSMTP();
$mail->Username = $this->smtp['smtp_usr'];
$mail->Password = $this->smtp['smtp_psw'];
$mail->SMTPAuth = $this->smtp['smtp_auth'] ? true : false;
}
if ($this->smtp['smtp_from_email']) {
$mail->SetFrom($this->smtp['smtp_from_email'], $this->smtp['smtp_from_name']);
} else {
$mail->SetFrom($this->smtp['smtp_server'], $this->smtp['smtp_usr']);
}
if (is_array($this->to)) {
foreach ($this->to as $key => $val) {
$name = is_numeric($key) ? "" : $key;
$mail->AddAddress($val, $name);
}
} else {
$mail->AddAddress($this->to, $this->to_name);
}
if (!empty($this->smtp['smtp_reply_email'])) {
$mail->AddReplyTo($this->smtp['smtp_reply_email'], $this->smtp['smtp_reply_name']);
}
if ($this->cc) {
if (is_array($this->cc)) {
foreach ($this->cc as $keyc => $valcc) {
$name = is_numeric($keyc) ? "" : $keyc;
$mail->AddCC($valcc, $name);
}
} else {
$mail->AddCC($this->cc, $this->cc_name);
}
}
if ($this->attach) {
if (is_array($this->attach)) {
foreach ($this->attach as $key => $val) {
$mail->AddAttachment($val);
}
} else {
$mail->AddAttachment($this->attach);
}
}
// $mail->SMTPSecure = 'ssl';
$mail->SMTPSecure = "tls";
$mail->WordWrap = 50;
$mail->IsHTML($this->is_html);
$mail->Subject = $this->subject;
$mail->Body = $this->body;
$mail->AltBody = "";
// return $mail->Body;
return $mail->Send();
}
示例6: send
function send($o, $to, $from, $subject, $body, $headers)
{
$mail = new PHPMailer(true);
$mail->IsSMTP();
$mail->SMTPDebug = 0;
// enables SMTP debug information (for testing)
$mail->SMTPAuth = $this->api->getConfig("tmail/phpmailer/username", null) ? true : false;
// enable SMTP authentication
$mail->Host = $this->api->getConfig("tmail/smtp/host");
$mail->Port = $this->api->getConfig("tmail/smtp/port");
$mail->Username = $this->api->getConfig("tmail/phpmailer/username", null);
$mail->Password = $this->api->getConfig("tmail/phpmailer/password", null);
$mail->SMTPSecure = 'tls';
$mail->AddReplyTo($this->api->getConfig("tmail/phpmailer/reply_to"), $this->api->getConfig("tmail/phpmailer/reply_to_name"));
$mail->AddAddress($to);
$mail->Subject = $subject;
$mail->MsgHTML($body);
$mail->AltBody = null;
$mail->IsHTML(true);
$bcc = $this->api->getConfig("tmail/phpmailer/bcc", null);
if ($bcc) {
$bcc_name = $this->api->getConfig("tmail/phpmailer/bcc_name", null);
$mail->AddBCC($bcc, $bcc_name);
}
$internal_header_map = array("Content-Type" => "ContentType");
$void_headers = array("MIME-Version");
$fromAdded = false;
foreach (explode("\n", $headers) as $h) {
if (preg_match("/^(.*?):(.*)\$/", $h, $t)) {
if (strtolower($t[1]) == "from" && $t[2]) {
$mail->SetFrom($t[2]);
$fromAdded = true;
continue;
}
if (isset($internal_header_map[$t[1]])) {
$key = $internal_header_map[$t[1]];
$mail->{$key} = $t[2];
continue;
} else {
if (in_array($t[1], $void_headers)) {
continue;
}
}
}
$mail->AddCustomHeader($h);
}
if (!$fromAdded) {
$mail->SetFrom($this->api->getConfig("tmail/phpmailer/from"), $from ? "" : $this->api->getConfig("tmail/phpmailer/from_name"));
$mail->AddReplyTo($this->api->getConfig("tmail/phpmailer/reply_to"), $this->api->getConfig("tmail/phpmailer/reply_to_name"));
}
$mail->Send();
}
示例7: sendEmail
function sendEmail($email,$subjectMail,$bodyMail,$email_back){
$mail = new PHPMailer(true);
$mail->IsSMTP(); // telling the class to use SMTP
try {
//$mail->Host = SMTP_HOST; // SMTP server
$mail->SMTPDebug = 0; // enables SMTP debug information (for testing)
$mail->SMTPAuth = true; // enable SMTP authentication
$mail->Host = SMTP_HOST; // sets the SMTP server
$mail->Port = SMTP_PORT; // set the SMTP port for the GMAIL server
$mail->Username = SMTP_USER; // SMTP account username
$mail->Password = SMTP_PASSWORD; // SMTP account password
$mail->AddAddress($email, ''); // SMTP account password
$mail->SetFrom(SMTP_EMAIL, SMTP_NAME);
$mail->AddReplyTo($email_back, SMTP_NAME);
$mail->Subject = $subjectMail;
$mail->AltBody = 'To view the message, please use an HTML compatible email viewer!'; // optional - MsgHTML will create an alternate automaticall//y
$mail->MsgHTML($bodyMail) ;
if(!$mail->Send()){
$success='0';
$msg="Error in sending mail";
}else{
$success='1';
}
} catch (phpmailerException $e) {
$msg=$e->errorMessage(); //Pretty error messages from PHPMailer
} catch (Exception $e) {
$msg=$e->getMessage(); //Boring error messages from anything else!
}
//echo $msg;
}
示例8: smtpMailer
function smtpMailer($to, $from, $from_name, $subject, $body)
{
$mail = new \PHPMailer();
// Cree un nouvel objet PHPMailer
$mail->IsSMTP();
// active SMTP
$mail->IsHTML(true);
$mail->CharSet = "utf-8";
$mail->SMTPDebug = 0;
// debogage: 1 = Erreurs et messages, 2 = messages seulement
$mail->SMTPAuth = true;
// Authentification SMTP active
$mail->SMTPSecure = 'ssl';
// Gmail REQUIERT Le transfert securise
$mail->Host = 'smtp.gmail.com';
$mail->Port = 465;
$mail->Username = GMailUSER;
$mail->Password = GMailPWD;
$mail->SetFrom($from, $from_name);
$mail->Subject = $subject;
$mail->Body = $body;
$mail->AddAddress($to);
$mail->setLanguage('fr', '/optional/path/to/language/directory/');
//debug($mail);
if (!$mail->Send()) {
$errorMail = 'Mail error: ' . $mail->ErrorInfo;
}
}
示例9: _email
public static function _email($options = array())
{
require_once 'PHPMailerAutoload.php';
//require_once 'class.phpmailer.php';
$options['fromEmail'] = !empty($options['fromEmail']) ? $options['fromEmail'] : SUPERADMIN_EMAIL;
$options['fromName'] = !empty($options['fromName']) ? $options['fromName'] : DONOTREPLYNAME;
try {
$mail = new PHPMailer();
$mail->IsSMTP();
$mail->SMTPDebug = 0;
// debugging: 1 = errors and messages, 2 = messages only
$mail->SMTPAuth = true;
$mail->Username = MAIL_USERNAME;
$mail->Password = MAIL_PASSWORD;
$mail->SMTPSecure = MAIL_TLS;
$mail->Host = MAIL_SMTP;
$mail->Port = MAIL_PORT;
$mail->IsHTML(true);
$mail->SetFrom($options['fromEmail']);
$mail->Subject = $options['subject'];
$mail->Body = $options['message'];
$mail->AddAddress($options['toEmail']);
if (!$mail->Send()) {
$expError = $mail->ErrorInfo;
$a = 'error';
} else {
//echo "Message has been sent";
$a = 'true';
}
} catch (phpmailerException $e) {
$expError = $e->errorMessage();
$a = 'error';
}
return $a;
}
示例10: addAddress
/**
*
* Can be used to add various types of address
*
* @param string $type
* @param $address
* @param string $name
* @throws \InvalidArgumentException
* @return $this
* @author Tim Perry
*/
public function addAddress($type, $address, $name = '')
{
if (empty($address) || filter_var($address, FILTER_VALIDATE_EMAIL) === false) {
$message = "Invalid address please provide a valid email address";
throw new \InvalidArgumentException($message);
}
switch ($type) {
default:
case 'to':
$this->mailer->AddAddress($address, $name);
break;
case 'from':
$this->mailer->SetFrom($address, $name);
break;
case 'bcc':
$this->mailer->AddBCC($address, $name);
break;
case 'cc':
$this->mailer->AddCC($address, $name);
break;
case 'replyto':
$this->mailer->AddReplyTo($address, $name);
break;
}
return $this;
}
示例11: send
function send($to, $subject, $body, $ph = array())
{
error_reporting(E_ALL);
// replace ph in body
if (0 < count($ph)) {
foreach ($ph as $key => $value) {
$subject = str_replace("{" . $key . "}", $value, $subject);
$body = str_replace("{" . $key . "}", $value, $body);
}
}
// file_put_contents(PATH_CACHE . "email.html", $body);
$mail = new \PHPMailer();
$mail->charSet = "UTF-8";
$mail->IsSMTP();
$mail->SMTPDebug = 0;
$mail->SMTPAuth = true;
if (MAIL_SECURE != '') {
$mail->SMTPSecure = MAIL_SECURE;
}
$mail->Host = MAIL_HOST;
$mail->Port = MAIL_PORT;
$mail->Username = MAIL_USER;
$mail->Password = MAIL_PASS;
$mail->Subject = $subject;
$mail->SetFrom(MAIL_USER);
$mail->AddAddress($to);
$mail->MsgHTML($body);
if (!$mail->Send()) {
echo $mail->ErrorInfo;
}
}
示例12: notify_user
/**
* Send an email notification to a user
*
* @static
* @since 1.1.0
* @param string $user_id User object_id
* @param string $subject Email subject line
* @param string $message Email body
*/
public static function notify_user($user_id, $subject, $message, $short_text = null)
{
$error = new argent_error();
if (!class_exists('PHPMailer')) {
$error->add('1042', 'PHPMailer is not available', NULL, 'argent_notification');
}
if ($error->has_errors()) {
return $error;
}
$mail = new PHPMailer();
$mail->AddReplyTo(NOTIFICATION_FROM_MAIL, NOTIFICATION_FROM_NAME);
$mail->SetFrom(NOTIFICATION_FROM_MAIL, NOTIFICATION_FROM_NAME);
$user_data = argent_uauth::user_get_data($user_id);
if (argent_error::check($user_data)) {
return $user_data;
}
$mail->AddAddress($user_data['email'], $user_data['display_name']);
$mail->Subject = $subject;
$mail->AltBody = "To view the message, please use an HTML compatible email viewer!";
// optional, comment out and test
$merge_fields = array('user_name' => $user_data['display_name'], 'email' => $user_data['email'], 'body' => $message, 'subject' => $subject, 'intro' => $short_text);
$message_body = self::merge_template(ABSOLUTE_PATH . 'argent/html_email_templates/basic.html', $merge_fields);
if (argent_error::check($message_body)) {
return $message_body;
}
$mail->MsgHTML($message_body);
if (!$mail->Send()) {
$error->add('1040', 'Error sending mail', $mail->ErrorInfo, 'argent_notification');
return $error;
} else {
return 'Mail sent to ' . $user_data['email'];
}
}
示例13: email_senden
function email_senden($email, $username, $password)
{
$empfaenger = $email;
$betreff = CONFIG_SITE_NAME . ': Willkommen';
$nachricht = "Hallo " . $username . ",\n\nDu hast Dich erfolgreich auf " . CONFIG_SITE_DOMAIN . " registriert. Bitte logge Dich jetzt mit Deinen Benutzerdaten ein, um Deinen Account zu aktivieren. Und dann kann es auch schon losgehen ...\n\nDamit Du Dich anmelden kannst, findest Du hier noch einmal Deine Benutzerdaten:\n\nE-Mail: " . $email . "\nBenutzername: " . $username . "\nPasswort: " . $password . "\n\nWir wünschen Dir noch viel Spaß beim Managen!\n\nSportliche Grüße\n" . CONFIG_SITE_NAME . "\n" . CONFIG_SITE_DOMAIN . "\n\n------------------------------\n\nDu erhältst diese E-Mail, weil Du Dich auf " . CONFIG_SITE_DOMAIN . " mit dieser Adresse registriert hast. Du kannst Deinen Account jederzeit löschen, nachdem Du Dich eingeloggt hast, sodass Du anschließend keine E-Mails mehr von uns bekommst. Bei Missbrauch Deiner E-Mail-Adresse meldest Du Dich bitte per E-Mail unter " . CONFIG_SITE_EMAIL;
if (CONFIG_EMAIL_PHP_MAILER) {
require './phpmailer/PHPMailerAutoload.php';
$mail = new PHPMailer();
// create a new object
$mail->CharSet = CONFIG_EMAIL_CHARSET;
$mail->IsSMTP();
$mail->SMTPAuth = CONFIG_EMAIL_AUTH;
$mail->SMTPSecure = CONFIG_EMAIL_SECURE;
$mail->Host = CONFIG_EMAIL_HOST;
$mail->Port = CONFIG_EMAIL_PORT;
$mail->Username = CONFIG_EMAIL_USER;
$mail->Password = CONFIG_EMAIL_PASS;
$mail->SetFrom(CONFIG_EMAIL_FROM, CONFIG_SITE_NAME);
$mail->Subject = $betreff;
$mail->Body = $nachricht;
$mail->AddAddress($empfaenger);
$mail->Send();
} else {
$header = "From: " . CONFIG_SITE_NAME . " <" . CONFIG_SITE_EMAIL . ">\r\nContent-type: text/plain; charset=utf-8";
mail($empfaenger, $betreff, $nachricht, $header);
}
}
示例14: Send_Mail
function Send_Mail($to, $subject, $body)
{
require 'class.phpmailer.php';
$from = "nguyenduonghaui94@gmail.com";
$mail = new PHPMailer();
$mail->IsSMTP(true);
// use SMTP
$mail->IsHTML(true);
$mail->SMTPAuth = true;
// enable SMTP authentication
$mail->Host = "tls://smtp.gmail.com";
// Amazon SES server, note "tls://" protocol
$mail->Port = 465;
// set the SMTP port
$mail->Username = "nguyenduonghaui94@gmail.com";
// SMTP username
$mail->Password = "lenguyen3110";
// SMTP password
$mail->SetFrom($from, 'HELLO');
$mail->AddReplyTo($from, 'Reply');
//$mail->Body= "kiểm tra email bạn nhé";
//$mail->AltBody = "Bạn sao vậy Tí";
$mail->Subject = $subject;
$mail->MsgHTML($body);
$address = $to;
$mail->AddAddress($address, $to);
$mail->Send();
}
示例15: Send_Mail
function Send_Mail($to, $subject, $body)
{
require 'class.phpmailer.php';
$from = "info@sealdek.com";
$mail = new PHPMailer();
$mail->IsSMTP(true);
// SMTP
$mail->SMTPAuth = true;
// SMTP authentication
$mail->Mailer = "smtp";
$mail->Host = "tls://email-smtp.us-east.amazonaws.com";
// Amazon SES
$mail->Port = 465;
// SMTP Port
$mail->Username = "Amazon SMTP Username";
// SMTP Username
$mail->Password = "Amazon SMTP Password";
// SMTP Password
$mail->SetFrom($from, 'From Name');
$mail->AddReplyTo($from, '9lessons Labs');
$mail->Subject = $subject;
$mail->MsgHTML($body);
$address = $to;
$mail->AddAddress($address, $to);
}