First meeting

This is the first time we met, to share something of it?

Share a little about how to send e-mail Sina cloud SAE application in it.

First, we have to open cloud mail service, you can call after the turn of the cloud Sina Mail API

After the open, we can configure files,

First built a name 'resp' (also called hello world line) PHP file,

Click the top left corner of the code is to manage the plus icon,

After the completed file name (the file name with the suffix was) on it.

After completed, the current folder is more than a name called 'resp.php ' files,

After the copy is to write code.

The following piece of code written 'resp.php' file.

Code:

<?php
$brand = $_SERVER['HTTP_USER_AGENT'];
$ip = $_SERVER["REMOTE_ADDR"];
$nowtime = date("Y-m-d H:i:s");
$mail = new SaeMail();
$ret = $mail->quickSend( '收件邮箱' , '邮件标题' , $ip."\r\n".'在'.$nowtime.'访问了你的网站'."\n访客设备信息:".$brand , '发件邮箱' , '发件邮箱密码' );
if ($ret === false)
var_dump($mail->errno(), $mail->errmsg());
?>

In this step, you need to pay attention to is your 'Sent mailbox' was open SMTP function,

And 'Outgoing mail password' required to complete is SMTP client authorization code

Instead of the mailbox password (if you opened a service authorization code).

At this point,

PHP file is set up.

Next, is to call this PHP script when the user enters the page to send mail.

Call is very simple, you just need to like to introduce external js script as it introduced it.

(Even if you are not introduced into the external js, you can directly following code is inserted into the body tag)

Code:

<script type="text/javascript" src="./resp.php"></script>

Once configured, do not forget to save the point oh,

After a user visits the page

Probably about five minutes visitors will receive mail

Go try it

Published 10 original articles · won praise 0 · Views 488

Guess you like

Origin blog.csdn.net/weixin_44549795/article/details/103360153