dounei5721 2014-06-24 08:24
浏览 17

如何创建直接向Gmail发送电子邮件的表单?

I'm a front-end designer, so my PHP skills are pretty basic. For my personal portfolio, I want to make a contact form which sends a message straight to my gmail address. I'm having trouble making this happen. Here's my code:

<?php
    error_reporting(0);
    $action=$_REQUEST['action'];
    if ($action=="") {
?>
<form action="" method="POST" enctype="multipart/form-data">
<h2>Form</h2>
<input type="hidden" name="action" value="submit">
<input name="name" type="text" value="" placeholder="Name"/><br>
<input name="email" type="text" value="" placeholder="Email"/><br>
<textarea name="message" placeholder="Message"></textarea><br>
<input name="cv" checked="true"> Yes, I would like to receive ****'s resume.<br>
<input type="submit" value="Send"/>
</form>
<?php
    } else {
        $name=$_REQUEST['name'];
        $email=$_REQUEST['email'];
        $message=$_REQUEST['message'];
        $cv=$_REQUEST['cv'];
        if (($name=="")||($email=="")||($message=="")) {
            echo "All fields are required. Please return to the <a href=\"\">form</a>.";
        } else {
            $from="From: $name<$email>
Return-path: $email";
            $subject="New message sent from your form";
            $curriculum="";
            if(isset($_REQUEST['cv'])){
                $curriculum="(!) This person would like to receive my resume.";
            }
            $cmessage=$message . "

" . $curriculum;
            mail("my-email@gmail.com", $subject, $cmessage, $from);
            echo "Message sent!";
        }
    }  
?>

I'm not getting an email whenever I try filling out the form myself. What seems to be the problem?

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 C++ yoloV5改写遇到的问题
    • ¥20 win11修改中文用户名路径
    • ¥15 win2012磁盘空间不足,c盘正常,d盘无法写入
    • ¥15 用土力学知识进行土坡稳定性分析与挡土墙设计
    • ¥70 PlayWright在Java上连接CDP关联本地Chrome启动失败,貌似是Windows端口转发问题
    • ¥15 帮我写一个c++工程
    • ¥30 Eclipse官网打不开,官网首页进不去,显示无法访问此页面,求解决方法
    • ¥15 关于smbclient 库的使用
    • ¥15 微信小程序协议怎么写
    • ¥15 c语言怎么用printf(“\b \b”)与getch()实现黑框里写入与删除?