如何在PHP中发送电子邮件 [英] How to send email in php

查看:130
本文介绍了如何在PHP中发送电子邮件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,



我是php的新手。



如何发送电子邮件PHP。我尝试了一些网站上提供的代码,但我没有收到任何电子邮件。



请帮帮我们。

< br $>
谢谢



我的尝试:



$ to =abdulsubhan.it@gmail.com;

$ subject =从php发送邮件;





$ message =这是HTML消息。;

$ message。=

这是标题。

;



$ header =来自:abc@somedomain.com \\\\ n;

$ header =抄送: subhani.029@gmail.com \\\\ n;

$ header。=MIME-Version:1.0 \\ n;

$ header。=Content-type:text / html\r\ n;



$ retval = mail($ to,$ subject,$ message,$标题);



if($ retval == true){

echo消息发送成功...;

}否则{

echo无法发送消息...遇到错误!;

}

?>



成功消息即将发布但不是电子邮件。



我有点困惑。

这个php代码不是有任何smtp变量,来自电子邮件密码,什么都没有......

会直接发送这封电子邮件吗?

Hi guys,

I'm new to php.

how to send email in php. i have tried some code which is available on websites, but i'm not getting any email.

please help me guys.

Thanks

What I have tried:

$to = "abdulsubhan.it@gmail.com";
$subject = "Sent mail from php";


$message = "This is HTML message.";
$message .= "

This is headline.

";

$header = "From:abc@somedomain.com \r\n";
$header = "Cc:subhani.029@gmail.com \r\n";
$header .= "MIME-Version: 1.0\r\n";
$header .= "Content-type: text/html\r\n";

$retval = mail ($to,$subject,$message,$header);

if( $retval == true ) {
echo "Message sent successfully...";
}else {
echo "Message could not be sent...Error Encountered!";
}
?>

Success message is coming but not email.

i'm little bit confused.
this php code is not having any smtp variables, from email-password, nothing...
Directly will send this email?

推荐答案

to =abdulsubhan。 it@gmail.com;
to = "abdulsubhan.it@gmail.com";


subject =从php发送邮件;




subject = "Sent mail from php";



message =这是HTML消息。;
message = "This is HTML message.";


这篇关于如何在PHP中发送电子邮件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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