【问题标题】:How to save sent email in sen box using phpmailer [duplicate]如何使用phpmailer将发送的电子邮件保存在邮箱中[重复]
【发布时间】:2018-09-25 23:48:08
【问题描述】:

我正在使用 phpmailer 向我的订阅者发送电子邮件。电子邮件已成功发送给我的客户,但我的发件箱中没有收到电子邮件。有没有办法在已发送的框中保存发送电子邮件???任何帮助都将是非常可观的。这是我的代码:

$db_host = "localhost";
$db_username = "root";
$db_pass = "";
$link= mysqli_connect("$db_host","$db_username","$db_pass", "db") or die ("could not connect to mysql"); 
//if($link){echo "connect";}
// Import PHPMailer classes into the global namespace
// These must be at the top of your script, not inside a function
use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\Exception;

//Load Composer's autoloader
require 'vendor/autoload.php';


$mail = new PHPMailer(true);                              // Passing `true` enables exceptions
try {
     $query = "select customer_email from subscribers";
     $result = mysqli_query($link, $query) or die("No customer in the table");;

     while($values = mysqli_fetch_array($result)){

         $toemail = $values['customer_email'];


    //Server settings
    $mail->SMTPDebug = 1;                                 // Enable verbose debug output
    $mail->isSMTP();                                      // Set mailer to use SMTP
    $mail->Host = '(myhost)';  // Specify main and backup SMTP servers
    $mail->SMTPAuth = true;                               // Enable SMTP authentication
    $mail->Username = '(my email)';                 // SMTP username
    $mail->Password = '(my password)';                           // SMTP password
    $mail->SMTPSecure = 'tls';                            // Enable TLS encryption, `ssl` also accepted
    $mail->Port = 587;                                    // TCP port to connect to

    //Recipients
    $mail->setFrom('haris.khan@premier.com.pk', 'Premier');
    $mail->addAddress(''.$toemail.'', ''.$name.'');     // Add a recipient
    $mail->addReplyTo('haris.khan@premier.com.pk', 'Information');

    //Content
    $mail->isHTML(true);                                  // Set email format to HTML
    $mail->Subject = 'Here is the subject for IT';
    $mail->Body    = 'This is the HTML message body <b>in bold!</b>';
    $mail->AltBody = 'This is the body in plain text for non-HTML mail clients';

    $mail->send();
   echo 'Message has been sent';
}
} catch (Exception $e) {
    echo 'Message could not be sent. Mailer Error: ', $mail->ErrorInfo;
}

【问题讨论】:

  • 你用的是什么服务器?
  • 您只是发送邮件,没有给出将发送的邮件保存在某处的代码;)
  • 我正在使用 namecheap 主机

标签: php phpmailer


【解决方案1】:

保存已发送的电子邮件副本是 Outlook、gmail 等邮件程序的一项功能。

如果您想存档已发送邮件的副本,您可以将电子邮件密送至另一个(或相同)电子邮件地址。然后在邮箱上设置过滤规则,将其移动到发送目录。

【讨论】:

  • 这不是真的...如上,您可以自动在 Sent 文件夹中创建 SENT 电子邮件。
猜你喜欢
  • 2019-04-16
  • 2014-07-04
  • 2021-07-16
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2017-01-16
相关资源
最近更新 更多