html 带有SMS选项的PHP SMTP电子邮件示例

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了html 带有SMS选项的PHP SMTP电子邮件示例相关的知识,希望对你有一定的参考价值。

<?php
// http://phpmailer.worxware.com/?pg=examplebsmtp
	
	$name = $_POST['name'] ; 
	$phone = $_POST['phone'] ;
	$message = $name . '<br>' . $phone . '<br>' . $_POST['message']   ;	
	
	
	require 'PHPMailerAutoload.php';
	
	//PHPMailer Object
	$mail = new PHPMailer;
	 
	// Instantiate Class
	$mail = new PHPMailer();
	 
	// Set up SMTP
	$mail->IsSMTP();                // Sets up a SMTP connection
	$mail->SMTPDebug  = 2;          // This will print debugging info
	$mail->SMTPAuth = true;         // Connection with the SMTP does require authorization
	$mail->SMTPSecure = "tls";      // Connect using a TLS connection
	$mail->Host = "smtp.gmail.com";
	$mail->Port = 587;
	$mail->Encoding = '7bit';       // SMS uses 7-bit encoding
	// set email format to HTML
	$mail->IsHTML(true);
	 
	// Authentication
	$mail->Username   = "juan@popcreativegroup.com"; // Login
	$mail->Password   = "popjuan7480#"; // Password
	 
	 
	// Compose
	$mail->AddReplyTo("alex@popcreativegroup.com","7866835225");
	// $mail->setFrom('popadmin@popcreativegroup.com', 'POP Admin');
	$mail->setFrom('popadmin@popcreativegroup.com', $name ) ;
	$mail->Subject = "New Mobile Message";     // Subject (which isn't required)
	$mail->Body = $message;        // Body of our message
	 
	// Send To alex
	 $mail->AddAddress( "7866835225@txt.att.net" ); // Where to send it
	//$mail->AddAddress( "juan@popcreativegroup.com" ); // Where to send it
	
	
	

	if(!$mail->Send())
	{
		echo "Message could not be sent. <p>";
		echo "Mailer Error: " . $mail->ErrorInfo;
		exit;
	}
	
	echo "<br><br>Thank you for contacting us. We will be in touch with you very soon.";	
<div class="container">
<div class="row">
  
  <form  action="email.php" method="post" >
    <div class="col-lg-6">
      <div class="form-group">
        <label for="InputName">Your Name</label>
        <div class="input-group">
          <input type="text" class="form-control" name="name" id="name" placeholder="Enter Name" >
          <span class="input-group-addon"><i class="glyphicon glyphicon-ok form-control-feedback"></i></span></div>
      </div>
      <div class="form-group">
        <label for="InputEmail">Your Phone Number</label>
        <div class="input-group">
          <input type="phone" class="form-control" id="phone" name="phone" placeholder="305-123-1337"   >
          <span class="input-group-addon"><i class="glyphicon glyphicon-ok form-control-feedback"></i></span></div>
      </div>
      <div class="form-group">
        <label for="InputMessage">Message</label>
        <div class="input-group"
>
          <textarea name="message" id="message" class="form-control" rows="5" ></textarea>
          <span class="input-group-addon"><i class="glyphicon glyphicon-ok form-control-feedback"></i></span></div>
      </div>

      <input type="submit" name="submit"  value="Submit" class="btn btn-info pull-right">
    </div>
  </form>
  <hr class="featurette-divider hidden-lg">

</div>

</div>

以上是关于html 带有SMS选项的PHP SMTP电子邮件示例的主要内容,如果未能解决你的问题,请参考以下文章

在 Linux 上使用带有 SMTP 服务器的默认 PHP 邮件功能

PHP发送带有SMTP错误的电子邮件:警告:stream_socket_enable_crypto():语言字符串加载失败:tls

(PHP 初学者帮助)如果您打算使用 SMTP,请在此行之后添加您的 SMTP 代码

通过 SMTP 发送带有附件、纯文本/文本和文本/html 的电子邮件

带有多个附件 + html 的 SMTP 邮件 Mime

带有 XAMPP 的 SMTP 服务器?