LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 06-22-2018, 03:17 AM   #1
ragurithvik
LQ Newbie
 
Registered: Jun 2018
Posts: 2

Rep: Reputation: Disabled
php mail function


hello friends i have one doubt i have use Php Mail function..and send message to my gmail account i have use to two code.code one only send to web mail not send to my gmail account..but second code it working and this same code..any one plz come me...
my php codes...
**Firscode**
<?php
if(isset($_POST['email']))
{
$name=$_POST['name'];
$email=$_POST['email'];
$phone=$_POST['mobile'];
$message=$_POST['message'];
$to='info@jeyamdecoration.com';
$headers = "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-type:text/html;charset=UTF-8" . "\r\n";
$headers .= 'From: info@azasoft.com' . "\r\n" .'Reply-To: info@azasoft.com' . "\r\n" . 'X-Mailer: PHP/' . phpversion();
$mail_message='<table width="100%" border="0" cellspacing="0" cellpadding="0" bgcolor="#cccccc">

<tr>
<td><table width="600" border="0" cellspacing="0" cellpadding="0" bgcolor="#FFFFFF" align="center">
<tr>
<td><table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr bgcolor="#ED1B24">
<td width="61"><a href= "" target="_blank"><img src="" height="56" style="margin-left: 12px;" border="0" alt=""/></a></td>
<td width="393"><table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td height="46" align="right" valign="middle"><table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="67%"><font style="font-family: Lobster Two, cursive; color:#fff; font-size:8px; text-transform:uppercase"><a href= "#" style="color:#fff; text-decoration:none; font-family:Georgia, Times New Roman, Times, serif; font-size:16px;"><strong>Contact Form</strong></a></font></td><td width="4%">&nbsp;</td>
</tr>
</table></td>
</tr>
</table></td>
</tr>
</table></td>
</tr>
<tr>
<td align="center">&nbsp;</td>
</tr>
<tr>
<td>&nbsp;</td>
</tr>
<tr>
<td><table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="10%">&nbsp;</td>
<td width="80%" align="left" valign="top"><font style="font-family: Georgia, Times New Roman, Times, serif; color:#010101; font-size:24px"><strong><em>Welcome,</em></strong></font><br />
<br />
<font style="font-family: Verdana, Geneva, sans-serif; color:#666766; font-size:13px; line-height:21px">
The Following Person contact Jeyam Decoration<br /><br /></font>
</td>
<td width="10%">&nbsp;</td>
</tr>
<tr>
<td colspan="3">
<table align="center" border="0" cellspacing="10" width="78%" style="background:#f7f7f7;margin-top:10px;border:1px solid #e8e8e8;border-radius:7px">
<tbody>
<tr>
<td width="62%" style="font-size:12px;font-family:Arial,Helvetica,sans-serif;color:#000;text-align:left;line-height:20px">Name:&nbsp;'.$name.'</a></td>
</tr>

<tr>
<td width="62%" style="font-size:12px;font-family:Arial,Helvetica,sans-serif;color:#000;text-align:left;line-height:20px">Email ID:&nbsp;'.$email.'</a></td>
</tr>

<tr>
<td width="62%" style="font-size:12px;font-family:Arial,Helvetica,sans-serif;color:#000;text-align:left;line-height:20px">Phone Number:&nbsp;'.$phone.'</a></td>
</tr>



<tr>
<td width="62%" style="font-size:12px;font-family:Arial,Helvetica,sans-serif;color:#000;text-align:left;line-height:20px"><font color="#000">Message:&nbsp;'.$message.'</font></a></td>
</tr>

</tbody>
</table>

</td>
</tr>

</table></td>
</tr>
<tr>
<td>&nbsp;</td>
</tr>
<tr>
<td>&nbsp;</td>
</tr>
<tr>
<td align="center"><font style="color:#000C99; font-size:10px; text-transform:uppercase"><strong>Thanks With Regards <br>Jeyam Decoration</strong></font></td>

</tr>
<tr>
<td>&nbsp;</td>
</tr>
<tr>
<td>&nbsp;</td>
</tr>
<tr>
</tr>
<tr bgcolor="#f2f2f2">
<td>&nbsp;</td>
</tr>
</table></td>
</tr>
</table>';

$mail_send=mail($to, $email, $mail_message, $headers);
if(isset($mail_send))
{
echo "<script> alert('Thank you for submitting the form. We will contact you soon!');
window.location = 'contact.html'; </script>";
}
else{
echo "<script>
alert('sorry');
window.location = 'contact.html'; </script>";
}

echo '<script language="javascript">;
echo alert("come here");
echo </script>';
}
?> } ?>
**Second code**
<?php
if(isset($_POST['email']))
{

$name=$_POST['name'];
$email=$_POST['email'];
$mobile=$_POST['phone'];
$jobjitle=$_POST['job'];
$messag=$_POST['message'];
$to='ragu.azasoft@gmail.com,info@anss.co.in,manager@anss.co.in,www.anss.co.in';
$from='info@azasoft.in';
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$headers .= 'From: ABS Travels<'.$from.">\r\n".'Reply-To: '.$from."\r\n" .'X-Mailer: PHP/' . phpversion();
$message='<table width="100%" border="0" cellspacing="0" cellpadding="0" bgcolor="#f2f2f2">
<tr>
<td><table width="600" border="0" cellspacing="0" cellpadding="0" bgcolor="#FFFFFF" align="center">
<tr>
<td><table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr bgcolor="#000">
<td width="61"><img src="http://www.anss.co.in/images/logo.png" height="56" style="margin-left: 12px;" border="0" alt=""/></a></td>
<td width="393"><table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td height="46" align="right" valign="middle"><table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="67%"><font style="font-family:Myriad Pro, Helvetica, Arial, sans-serif; color:#000C99; font-size:8px; text-transform:uppercase"><a href= "#" style="color:#fff; text-decoration:none; font-family:Georgia, Times New Roman, Times, serif; font-size:20px;"><strong></strong></a></font></td><td width="4%">&nbsp;</td>
</tr>
</table></td>
</tr>
</table></td>
</tr>
</table></td>
</tr>
<tr>
<td align="center">&nbsp;</td>
</tr>
<tr>
<td>&nbsp;</td>
</tr>
<tr>
<td><table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="10%">&nbsp;</td>
<td width="61"><a href= "" target="_blank"><img src="" height="56" style="margin-left: 12px;" border="0" alt=""/></a></td>
<td width="10%">&nbsp;</td>
</tr>
<tr>
<td colspan="3">
<table align="center" border="0" cellspacing="10" width="78%" style="background:#f7f7f7;margin-top:10px;border:1px solid #e8e8e8;border-radius:7px">
<tbody>
<tr>
<td width="62%" style="font-size:12px;font-family:Arial,Helvetica,sans-serif;color:#000;text-align:left;line-height:20px">First Name:&nbsp;'.$name.'</a></td>
</tr>
<tr>
<td width="62%" style="font-size:12px;font-family:Arial,Helvetica,sans-serif;color:#000;text-align:left;line-height:20px">Email:&nbsp;'.$email.'</a></td>
</tr>
<tr>
<td width="62%" style="font-size:12px;font-family:Arial,Helvetica,sans-serif;color:#000;text-align:left;line-height:20px">Phone Number:&nbsp;'.$mobile.'</a></td>
</tr>
<tr>
<td width="62%" style="font-size:12px;font-family:Arial,Helvetica,sans-serif;color:#000;text-align:left;line-height:20px">Job Title :&nbsp;'.$jobjitle.'</a></td>
</tr><tr>
<td width="62%" style="font-size:12px;font-family:Arial,Helvetica,sans-serif;color:#000;text-align:left;line-height:20px"> Message:&nbsp;'.$messag.'</a></td></tr>
<tr>
</tr>
</tbody>
</table>

</td>
</tr>

</table></td>
</tr>
<tr>
<td>&nbsp;</td>
</tr>
<tr>
<td>&nbsp;</td>
</tr>
<tr>
<td align="center"><font style="color:#000C99; font-size:10px; text-transform:uppercase"><strong>Thanks With Regards <br> Anns Crafters</strong></font></td>

</tr>
<tr>
<td>&nbsp;</td>
</tr>
<tr>
<td>&nbsp;</td>
</tr>
<tr>
<td align="center"><font style="color:#231f20; font-size:11.5px"><strong></strong></font></td>
</tr>
<tr>
<td>&nbsp;</td>
</tr>
</table></td>
</tr>
</table>';
$mail_send=mail($to, $email, $message, $headers);
if(isset($mail_send))
{
echo "<script> alert('Thank you for submitting the form. We will contact you soon!');
window.location = 'apply-online.html'; </script>";
}
else{
echo "<script>
alert('sorry');
window.location = 'apply-online.html'; </script>";
}

echo '<script language="javascript">;
echo alert("come here");
echo </script>';
}
?> } ?>
 
Old 06-22-2018, 02:53 PM   #2
NevemTeve
Senior Member
 
Registered: Oct 2011
Location: Budapest
Distribution: Debian/GNU/Linux, AIX
Posts: 4,852
Blog Entries: 1

Rep: Reputation: 1868Reputation: 1868Reputation: 1868Reputation: 1868Reputation: 1868Reputation: 1868Reputation: 1868Reputation: 1868Reputation: 1868Reputation: 1868Reputation: 1868
What exactly is the problem? (Other than non-using [code] and [/code] tags.)

Last edited by NevemTeve; 06-22-2018 at 11:24 PM.
 
Old 06-22-2018, 03:51 PM   #3
scasey
LQ Veteran
 
Registered: Feb 2013
Location: Tucson, AZ, USA
Distribution: CentOS 7.9.2009
Posts: 5,708

Rep: Reputation: 2210Reputation: 2210Reputation: 2210Reputation: 2210Reputation: 2210Reputation: 2210Reputation: 2210Reputation: 2210Reputation: 2210Reputation: 2210Reputation: 2210
Yes, I don't see a question there, and yes, please edit your post to put [code] tags around your code.
 
Old 06-23-2018, 04:43 AM   #4
ragurithvik
LQ Newbie
 
Registered: Jun 2018
Posts: 2

Original Poster
Rep: Reputation: Disabled
hello actually i'm used php mail function my mails not send to my gmail account ...but only send web-mail...my codes...bellow there..
 
Old 06-23-2018, 06:17 AM   #5
NevemTeve
Senior Member
 
Registered: Oct 2011
Location: Budapest
Distribution: Debian/GNU/Linux, AIX
Posts: 4,852
Blog Entries: 1

Rep: Reputation: 1868Reputation: 1868Reputation: 1868Reputation: 1868Reputation: 1868Reputation: 1868Reputation: 1868Reputation: 1868Reputation: 1868Reputation: 1868Reputation: 1868
check... your 'Spam' folder... in gmail...
 
Old 06-23-2018, 06:59 AM   #6
michaelk
Moderator
 
Registered: Aug 2002
Posts: 25,592

Rep: Reputation: 5880Reputation: 5880Reputation: 5880Reputation: 5880Reputation: 5880Reputation: 5880Reputation: 5880Reputation: 5880Reputation: 5880Reputation: 5880Reputation: 5880
You need to enable less secure apps in your gmail settings as well as using ssl. I use phpmailer

https://www.sitepoint.com/sending-emails-php-phpmailer/
 
Old 06-26-2018, 12:24 PM   #7
dogpatch
Member
 
Registered: Nov 2005
Location: Central America
Distribution: Mepis, Android
Posts: 490
Blog Entries: 4

Rep: Reputation: 238Reputation: 238Reputation: 238
Sometimes if Gmail marks an email as spam and you mark it as not spam, Gmail may from that point on accept mail from that same source with no further problem
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
How to send mail using PHP mail function On apache server kiran.ursal Linux - Server 2 04-29-2013 03:21 AM
mail() function in php ramzaher Linux - Newbie 4 04-29-2011 02:03 AM
PHP Mail function phantom_cyph Programming 6 05-15-2008 11:45 PM
HELP !!! php mail function akamaru607 Programming 22 08-26-2005 02:44 PM
PHP - mail function saravanan1979 Programming 2 08-06-2003 01:46 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 08:46 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration