PHP mail sending issue

Status
Not open for further replies.

celestale13

New Member
Messages
6
Reaction score
0
Points
1
Hi,

My PHP mail did not work as intended on x10hosting server, mail does not get sent/redirect page to FormToEmail.php. (after pressing the submit button on the Form.

This is my contactus.php
    1. <?php
    2. if(isset($_POST['submit'])){
    3. $to = "my@email.com"; // this is your Email address
    4. $from = "sender@email.com"; // this is the sender's Email address
    5. $first_name = $_POST['name'];
    6. $last_name = 'Citizen';
    7. $subject = "Subject: Test mail";
    8. $subject2 = "Copy of your form submission";
    9. $message = $first_name . " " . $last_name . " wrote the following:" . "\n\n" . $_POST['message'];
    10. $message2 = "Here is a copy of your message " . $first_name . "\n\n" . $_POST['message'];

    11. $headers = "From:" . $from;
    12. $headers2 = "From:" . $to;
    13. mail($to,$subject,$message,$headers);
    14. mail($from,$subject2,$message2,$headers2); // sends a copy of the message to the sender
    15. header('Location: FormToEmail.php');
    16. }
    17. ?>


    18. <form action="" method="post">
    19. First Name: <input type="text" name="first_name"><br>
    20. Last Name: <input type="text" name="last_name"><br>
    21. Email: <input type="text" name="email"><br>
    22. Message:<br><textarea rows="5" name="message" cols="30"></textarea><br>
    23. <input type="submit" name="submit" value="Submit">
    24. </form>
I checked that this is not a code problem because I tried it in another hosting server and it works perfectly fine. But I love to stick with x10hosting so I would rather stay here and see if this problem can be fixed.
 

essellar

Community Advocate
Community Support
Messages
3,295
Reaction score
227
Points
63
The From address must always be from an account belonging to your hosting account. (Otherwise you can send spoofed mail, often used for phishing and other malicious purposes.) If you need to reply to the users' mail, use the ReplyTo header, not the From.
 

celestale13

New Member
Messages
6
Reaction score
0
Points
1
The From address must always be from an account belonging to your hosting account. (Otherwise you can send spoofed mail, often used for phishing and other malicious purposes.) If you need to reply to the users' mail, use the ReplyTo header, not the From.

Do you mean Line 3
$to = "my@email.com"; // I already put in the email that I used to register for x10hosting, but the contact form is still not sending mails to my email.
The purpose of the Form in my webpage is to allow the visitors send me their "message" through the contact form.
I do not need to reply to the users' mail through my hosting server.
 

Dead-i

x10Hosting Support Ninja
Community Support
Messages
6,084
Reaction score
368
Points
83
Hi,

This is the From email address, on Line 4.
Code:
$from = "sender@email.com"; // this is the sender's Email address


The "From" email address must be on present on your account for the email to send. ;)

However, I checked our mail server, and it looks like several emails from your account's email address (celestal [@] xo7.x10hosting.com) were successfully sent to your email address. Did you receive these emails? :)

Thank you,
 
Status
Not open for further replies.
Top