简体   繁体   中英

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
$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.

I tried everything to send out the mails and no luck.

Any advice?

Please submit all of your code including <form..> tag.

Also can you replace your php code to this and try again:

<?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 . It's not hard to setup, even for someone just starting.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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