简体   繁体   English

php mail()不会发送电子邮件

[英]php mail() wont send email

I'm a beginning php coder (really beginner) and I need to make a postcard-sending script but it wont send my emails. 我是一名初学者php程序员(真的是初学者),我需要制作一张明信片发送脚本,但它不会发送我的电子邮件。

<?php
$to_name = $_REQUEST['to_name'];
$to_email = $_REQUEST['to_email'];
$subject = 'teszt';

$msg = 'proba';

mail($to_mail, $subject, $msg, 'From:' . 'teszt@valami.hu');
?>  

<label for='to_name''>Címzett neve:</label>
<input type='text' name='to_name' id='to_name' class='gbi' size='30'>
<label for='to_email''>Címzett email cime:</label>
<input type='text' name='to_email' id='to_email' class='gbi' size='30'>

<label for='name''>Az ön neve:</label>
<input type='text' name='name' id='name' class='gbi' size='30'>

<label for='email''>Az ön email cime:</label>
<input type='text' name='email' id='email' class='gbi' size='30'>

<label for='text''>Üzenet:</label>
<textarea name='text' id='text' class='pct' ></textarea>
<br>
<input type='submit' >

Yes it is it a form :) 是的,它是一种形式:)

So the point is I made 4 images, every for images have a different submit button, so when they click on it a for pops up for the image. 因此,关键是我制作了4张图像,每个图像都有一个不同的“提交”按钮,因此当他们单击它时,就会弹出该图像。

I tried everything to send out the mails and no luck. 我尽一切努力发送邮件,但没有运气。

Any advice? 有什么建议吗?

Please submit all of your code including <form..> tag. 请提交所有代码,包括<form..>标签。

Also can you replace your php code to this and try again: 也可以将您的php代码替换为该代码,然后重试:

<?php 
   if (!empty($_REQUEST['to_email'])) {
      $to_name = $_REQUEST['to_name'];
      $to_email = $_REQUEST['to_email'];
      $subject = 'teszt';
      $msg = 'proba';

      mail($to_mail, $subject, $msg );
   }
?>

I would suggest forgoing mail() all together, and using swiftmailer . 我建议一起放弃所有的mail(),并使用swiftmailer It's not hard to setup, even for someone just starting. 设置起来并不难,即使对于刚开始的人也是如此。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM