在php中,我使用mail()发送邮件,它不能保存在我发送的项目文件夹中 [英] In php , i have send a mail using mail() , it must not saved in my sent items folder

查看:101
本文介绍了在php中,我使用mail()发送邮件,它不能保存在我发送的项目文件夹中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用邮件功能发送邮件工作正常。但是我的问题是邮件发送时如何自动保存发送邮件文件夹中的邮件



im使用自己的smtp服务器和端口号是25



是php ini文件中需要的任何配置,或者我可以使用imap



我的代码如下

 <?php 
函数send_email($ from,$ to,$ subject,$ message){
$ headers =From:。 $从 \r\\\

$ headers。=Reply-To:。$ from。\r\\\
;
$ headers。=Return-Path:。$ from。\r\\\
;
$ headers。=Content-type:text / html\r\\\
;

if(mail($ to,$ subject,$ message,$ headers)){
echoemail sent;
} else {
echo无法发送电子邮件;
}
}

$ subject =Helloooo!;
$ message。=< html>< body>;
$ message。=< b>嘿,你今天好吗?< / b>;
$ message。=< br> Regards;
$ message。=< / body>< / html>;
send_email(frm addr,MYEMAILADDRESS@gmail.com,
$ subject,
$ message);
?>

frm addr是我自己的邮件服务器提供的网址



如果我使用上述功能发送邮件,如何将邮件存储或自动保存到我的已发送邮件文件夹



,谢谢adv



R.Saravanakumar

解决方案

你必须明白 mail()函数在远程服务器上工作。您发送电子邮件的功能不知道发送邮件文件夹的概念。



说,可能有可能拥有邮件服务器将邮件的副本放在运行在同一服务器上的IMAP邮箱的已发送文件夹中。这包括很多麻烦,而且需要root访问服务器。



一个更容易的解决方案是让mail()函数向您发送每个发送的副本邮件,并设置Outlook规则将这些邮件复制到发送文件夹中。



为此,您可以添加一个特定的字符串(如邮件发送形式1234567,一些随机数,不太可能在正常邮件中重复)发送您的副本的主题。然后,您的Outlook规则将会查找包含该主题的邮件,并将其移动到已发送文件夹(或任何其他文件夹中)。


Send email using mail function working fine. but my question is how to auto save the mail in sent items folder when mail sent

i m using own smtp server and port no is 25

is any config needed on php ini file or i may use imap

my code is as follows

<?php
function send_email($from, $to, $subject, $message){
 $headers = "From: ".$from."\r\n";
 $headers .= "Reply-To: ".$from."\r\n";
 $headers .= "Return-Path: ".$from."\r\n";
 $headers .= "Content-type: text/html\r\n"; 

 if (mail($to,$subject,$message,$headers) ) {
    echo "email sent";
 } else {
    echo "email couldn't be sent";
 }
}

$subject = "Helloooo!";
$message .= "<html><body>";
$message .= "<b>Hey! How are you today?</b>";
$message .= "<br>Regards";
$message .= "</body></html>";
send_email("frm addr", "MYEMAILADDRESS@gmail.com", 
 $subject , 
 $message);
?>

"frm addr" is my own web address which is provided by my mail server

how to store or automatically save the mails to my sent item folder whenever i send a mail using the above function

with thanks in adv

R.Saravanakumar

解决方案

You have to understand the mail() function works on a remote server. The function you send the E-Mail with does not know the concept of a "Sent mail" folder.

That said, it would probably be possible to have the mail server place a copy of the message in the "sent" folder of an IMAP mailbox running on the same server. That includes a lot of hassle, though, and requires root access to the server.

A much easier solution is having the mail() function send you a copy of every sent mail, and to set up an Outlook rule to copy those mails into your "sent" folder.

For that, you could for example add a specific string (like "mail sent from form 1234567", some random number that is unlikely to be repeated in a normal mail) to the subject when sending your copy. Your Outlook rule would then look out for mails containing that subject, and move them into the "Sent" folder (or any other folder, for that matter).

这篇关于在php中,我使用mail()发送邮件,它不能保存在我发送的项目文件夹中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆