Need help-Send email

Need help-Send email

am 11.09.2009 16:12:50 von Nagendra Prasad

--00504502c72b7ad16404734dea9b
Content-Type: text/plain; charset=ISO-8859-1

Hi All,

I want to send my sql database to the user email. But I don't have any Email
server or any email domain server. So, is their any way to use my localhost
to send emails to the user's email id. If it not possible is their a way
that I can use my Gmail to send an email through PHP?

Best,

--
Guru Prasad
Ubuntu Voice GTK+ Forum

--00504502c72b7ad16404734dea9b--

Re: Need help-Send email

am 12.09.2009 12:40:38 von Nagendra Prasad

--000e0ce040886b240804735f117b
Content-Type: text/plain; charset=ISO-8859-1

Hi all,

Below is the code that I have coded after replies from all of you. But
before that I want to thank all of you for your help. I have coded the email
code but still it is giving me an error. Please help me.


//sending email script

$to = "example@gmail.com";
$subject = "Email from admin";

if ($_POST['submit'])
{
//get data from form

$name = $_POST['name'];
$message = $_POST['message'];
if ($name&&$message)
{
$namelen = 20;
$messagelen = 300;
if (strlen($name)<=$namelen && strlen($message)<=$messagelen)
{
//everything is ok

ini_set("SMTP", "smtp.gmail.com");


$to = "example@gmail.com";

$subject = "Email from admin";
$header = "from: example@gmail.com";


$body = "Email from $name \n\n $message";


mail($to,$subject,$body,$header);
die();
}
else
die ("Max length of name is $namelen, and max length for message is 300");

}
else
die("you must enter a name");
}

?>



Name:

Message:









------------------------------------------------------------ --------------------------

Also I have simplified the code by just using the email() function but the
problem is its sending the mail in the SPAM. The code is below :

$to = "example@gmail.com";
$subject = "Test mail";
$message = "Hello! This is a simple email message.";
$from = "example@gmail.com";
$headers = "From: $from";
mail($to,$subject,$message,$headers);
echo "Mail Sent.";
?>

--000e0ce040886b240804735f117b--

Re: Re: Need help-Send email

am 12.09.2009 12:50:24 von muhsin

Is this related to PHP-DB?
Anyways, if I understands it correctly is that mail() is working but the
client is categorizing the mail received into the SPAM folder.This might
means your issue is not longer on that mail(), but on the your
mail-client filters.

GR
mrfroasty


nagendra prasad wrote:
> Hi all,
>
> Below is the code that I have coded after replies from all of you. But
> before that I want to thank all of you for your help. I have coded the email
> code but still it is giving me an error. Please help me.
>
> >
> //sending email script
>
> $to = "example@gmail.com";
> $subject = "Email from admin";
>
> if ($_POST['submit'])
> {
> //get data from form
>
> $name = $_POST['name'];
> $message = $_POST['message'];
> if ($name&&$message)
> {
> $namelen = 20;
> $messagelen = 300;
> if (strlen($name)<=$namelen && strlen($message)<=$messagelen)
> {
> //everything is ok
>
> ini_set("SMTP", "smtp.gmail.com");
>
>
> $to = "example@gmail.com";
>
> $subject = "Email from admin";
> $header = "from: example@gmail.com";
>
>
> $body = "Email from $name \n\n $message";
>
>
> mail($to,$subject,$body,$header);
> die();
> }
> else
> die ("Max length of name is $namelen, and max length for message is 300");
>
> }
> else
> die("you must enter a name");
> }
>
> ?>
>
>
>


> Name:

> Message:


>
>
>


>
>
>
>
> ------------------------------------------------------------ --------------------------
>
> Also I have simplified the code by just using the email() function but the
> problem is its sending the mail in the SPAM. The code is below :
>
> > $to = "example@gmail.com";
> $subject = "Test mail";
> $message = "Hello! This is a simple email message.";
> $from = "example@gmail.com";
> $headers = "From: $from";
> mail($to,$subject,$message,$headers);
> echo "Mail Sent.";
> ?>
>
>


--
Extra details:
OSS:Gentoo Linux
profile:x86
Hardware:msi geforce 8600GT asus p5k-se
location:/home/muhsin
language(s):C/C++,VB,VHDL,bash,PHP,SQL,HTML,CSS
Typo:40WPM
url:http://www.mzalendo.net


--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Re: Re: Need help-Send email

am 12.09.2009 12:57:08 von Nagendra Prasad

--001636c5a86f6ce6bf04735f4cb2
Content-Type: text/plain; charset=ISO-8859-1

Exactly, the mail-client filter is actively working for such mail. But when
I researched on Google I have found that to send an email using PHP we at
lest need a mail server domain. Also we have to set SMTP to send email to
inbox otherwise every mail-client will filter it and send it to SPAM folder.
Also, I am using WAMP to use all these codes so right now I don't have an
email server domain or something like that. Is their a way to set my PHP ini
file to use my Gmail SMTP and PORT settings so that I can at lest send
emails directly to inbox and later I will change it to some other email
client.

Thanks for the quick response :)

--001636c5a86f6ce6bf04735f4cb2--

Re: Re: Need help-Send email

am 12.09.2009 15:59:51 von Jack van Zanen

--0016e6d2716fb4f41e047361d82b
Content-Type: text/plain; charset=ISO-8859-1

what is the client email filter looking for to classify this as spam??
1. Mail from GMAIL? Bit rough considering the number of valid users
2. subject "Test mail" ? if so change subject to something more business
like
3. message "Hello! This is a simple email message"? I do not think so

Most likely culprit is number 2.


Jack van Zanen

-------------------------
This e-mail and any attachments may contain confidential material for the
sole use of the intended recipient. If you are not the intended recipient,
please be aware that any disclosure, copying, distribution or use of this
e-mail or any attachment is prohibited. If you have received this e-mail in
error, please contact the sender and delete all copies.
Thank you for your cooperation


2009/9/12 nagendra prasad

> Exactly, the mail-client filter is actively working for such mail. But when
> I researched on Google I have found that to send an email using PHP we at
> lest need a mail server domain. Also we have to set SMTP to send email to
> inbox otherwise every mail-client will filter it and send it to SPAM
> folder.
> Also, I am using WAMP to use all these codes so right now I don't have an
> email server domain or something like that. Is their a way to set my PHP
> ini
> file to use my Gmail SMTP and PORT settings so that I can at lest send
> emails directly to inbox and later I will change it to some other email
> client.
>
> Thanks for the quick response :)
>

--0016e6d2716fb4f41e047361d82b--

Re: Re: Need help-Send email

am 12.09.2009 17:11:00 von kyle.smith

--------------080600030802000106080405
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit

Mail from GMail coming from a non-gmail server? Yes, definately. Do
not use @gmail.com in the from address, see how that works.

Jack van Zanen wrote:
> what is the client email filter looking for to classify this as spam??
> 1. Mail from GMAIL? Bit rough considering the number of valid users
> 2. subject "Test mail" ? if so change subject to something more business
> like
> 3. message "Hello! This is a simple email message"? I do not think so
>
> Most likely culprit is number 2.
>
>
> Jack van Zanen
>
> -------------------------
> This e-mail and any attachments may contain confidential material for the
> sole use of the intended recipient. If you are not the intended recipient,
> please be aware that any disclosure, copying, distribution or use of this
> e-mail or any attachment is prohibited. If you have received this e-mail in
> error, please contact the sender and delete all copies.
> Thank you for your cooperation
>
>
> 2009/9/12 nagendra prasad
>
>
>> Exactly, the mail-client filter is actively working for such mail. But when
>> I researched on Google I have found that to send an email using PHP we at
>> lest need a mail server domain. Also we have to set SMTP to send email to
>> inbox otherwise every mail-client will filter it and send it to SPAM
>> folder.
>> Also, I am using WAMP to use all these codes so right now I don't have an
>> email server domain or something like that. Is their a way to set my PHP
>> ini
>> file to use my Gmail SMTP and PORT settings so that I can at lest send
>> emails directly to inbox and later I will change it to some other email
>> client.
>>
>> Thanks for the quick response :)
>>
>>
>
>

--------------080600030802000106080405--

Re: Re: Need help-Send email

am 12.09.2009 17:21:08 von Jack van Zanen

--0016368e1e376a27d7047362fbc3
Content-Type: text/plain; charset=ISO-8859-1

I thought he said he was using the gmail smtp server?


Jack van Zanen

-------------------------
This e-mail and any attachments may contain confidential material for the
sole use of the intended recipient. If you are not the intended recipient,
please be aware that any disclosure, copying, distribution or use of this
e-mail or any attachment is prohibited. If you have received this e-mail in
error, please contact the sender and delete all copies.
Thank you for your cooperation


2009/9/13 Kyle Smith

> Mail from GMail coming from a non-gmail server? Yes, definately. Do not
> use @gmail.com in the from address, see how that works.
>
>
> Jack van Zanen wrote:
>
> what is the client email filter looking for to classify this as spam??
> 1. Mail from GMAIL? Bit rough considering the number of valid users
> 2. subject "Test mail" ? if so change subject to something more business
> like
> 3. message "Hello! This is a simple email message"? I do not think so
>
> Most likely culprit is number 2.
>
>
> Jack van Zanen
>
> -------------------------
> This e-mail and any attachments may contain confidential material for the
> sole use of the intended recipient. If you are not the intended recipient,
> please be aware that any disclosure, copying, distribution or use of this
> e-mail or any attachment is prohibited. If you have received this e-mail in
> error, please contact the sender and delete all copies.
> Thank you for your cooperation
>
>
> 2009/9/12 nagendra prasad
>
> Exactly, the mail-client filter is actively working for such mail. But when
> I researched on Google I have found that to send an email using PHP we at
> lest need a mail server domain. Also we have to set SMTP to send email to
> inbox otherwise every mail-client will filter it and send it to SPAM
> folder.
> Also, I am using WAMP to use all these codes so right now I don't have an
> email server domain or something like that. Is their a way to set my PHP
> ini
> file to use my Gmail SMTP and PORT settings so that I can at lest send
> emails directly to inbox and later I will change it to some other email
> client.
>
> Thanks for the quick response :)
>
>
>
>

--0016368e1e376a27d7047362fbc3--

Re: Re: Need help-Send email

am 13.09.2009 04:02:24 von kyle.smith

--------------070903070200070600090503
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit

I guess I don't know enough about the gmail setup to know for sure, but
I imagine GMail's external SMTP server (i.e. the one used to process
mail being sent to @gmail.com addresses) isn't intended for people
sending mail from their gmail accounts. In which case, it's not going
to be thrilled about email coming in claiming to be FROM gmail.com.

I'd have to look more into their setup to be sure, but it's a good rule
of thumb to use addresses within your own domain for the From address.

- Kyle

Jack van Zanen wrote:
> I thought he said he was using the gmail smtp server?
>
>
> Jack van Zanen
>
> -------------------------
> This e-mail and any attachments may contain confidential material for
> the sole use of the intended recipient. If you are not the intended
> recipient, please be aware that any disclosure, copying, distribution
> or use of this e-mail or any attachment is prohibited. If you have
> received this e-mail in error, please contact the sender and delete
> all copies.
> Thank you for your cooperation
>
>
> 2009/9/13 Kyle Smith > >
>
> Mail from GMail coming from a non-gmail server? Yes, definately.
> Do not use @gmail.com in the from address, see
> how that works.
>
>
> Jack van Zanen wrote:
>> what is the client email filter looking for to classify this as spam??
>> 1. Mail from GMAIL? Bit rough considering the number of valid users
>> 2. subject "Test mail" ? if so change subject to something more business
>> like
>> 3. message "Hello! This is a simple email message"? I do not think so
>>
>> Most likely culprit is number 2.
>>
>>
>> Jack van Zanen
>>
>> -------------------------
>> This e-mail and any attachments may contain confidential material for the
>> sole use of the intended recipient. If you are not the intended recipient,
>> please be aware that any disclosure, copying, distribution or use of this
>> e-mail or any attachment is prohibited. If you have received this e-mail in
>> error, please contact the sender and delete all copies.
>> Thank you for your cooperation
>>
>>
>> 2009/9/12 nagendra prasad
>>
>>
>>> Exactly, the mail-client filter is actively working for such mail. But when
>>> I researched on Google I have found that to send an email using PHP we at
>>> lest need a mail server domain. Also we have to set SMTP to send email to
>>> inbox otherwise every mail-client will filter it and send it to SPAM
>>> folder.
>>> Also, I am using WAMP to use all these codes so right now I don't have an
>>> email server domain or something like that. Is their a way to set my PHP
>>> ini
>>> file to use my Gmail SMTP and PORT settings so that I can at lest send
>>> emails directly to inbox and later I will change it to some other email
>>> client.
>>>
>>> Thanks for the quick response :)
>>>
>>>
>>
>
>

--------------070903070200070600090503--

Re: Re: Need help-Send email

am 14.09.2009 01:40:55 von dmagick

nagendra prasad wrote:
> Hi all,
>
> Below is the code that I have coded after replies from all of you. But
> before that I want to thank all of you for your help. I have coded the email
> code but still it is giving me an error. Please help me.

.... and the error is what exactly?

> >
> //sending email script
>
> $to = "example@gmail.com";
> $subject = "Email from admin";
>
> if ($_POST['submit'])
> {
> //get data from form
>
> $name = $_POST['name'];
> $message = $_POST['message'];
> if ($name&&$message)
> {
> $namelen = 20;
> $messagelen = 300;
> if (strlen($name)<=$namelen && strlen($message)<=$messagelen)
> {
> //everything is ok
>
> ini_set("SMTP", "smtp.gmail.com");

Where's your smtp authentication? You can't just set the mail server and
that's it.

http://deepakssn.blogspot.com/2006/06/gmail-php-send-email-u sing-php-with.html

Use phpmailer (as this article suggests) and you'll have a lot better
chance of things working.

--
Postgresql & php tutorials
http://www.designmagick.com/


--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Re: Re: Need help-Send email

am 14.09.2009 11:18:36 von Richard Quadling

2009/9/14 Chris :
> nagendra prasad wrote:
>>
>> Hi all,
>>
>> Below is the code that I have coded after replies from all of you. But
>> before that I want to thank all of you for your help. I have coded the
>> email
>> code but still it is giving me an error. Please help me.
>
> ... and the error is what exactly?
>
>> >>
>> //sending email script
>>
>> $to =3D "example@gmail.com";
>> $subject =3D "Email from admin";
>>
>> if ($_POST['submit'])
>> {
>> //get data from form
>>
>> $name =3D $_POST['name'];
>> $message =3D $_POST['message'];
>> if ($name&&$message)
>> {
>> $namelen =3D 20;
>> $messagelen =3D 300;
>> if (strlen($name)<=3D$namelen && strlen($message)<=3D$messagelen)
>> {
>>  //everything is ok
>>
>>  ini_set("SMTP", "smtp.gmail.com");
>
> Where's your smtp authentication? You can't just set the mail server and
> that's it.
>
> http://deepakssn.blogspot.com/2006/06/gmail-php-send-email-u sing-php-with=
..html
>
> Use phpmailer (as this article suggests) and you'll have a lot better cha=
nce
> of things working.
>
> --
> Postgresql & php tutorials
> http://www.designmagick.com/
>
>
> --
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

Follow these steps...

1 - What is the domain of the recipient? gmail.com
2 - What is recipients SMTP server? nslookup -q=3Dmx gmail.com

[2009/09/14 10:10:58] [C:\] [] >nslookup -q=3Dmx gmail.com
Server: bv-vm-svr-1.bandvulc.local
Address: 10.0.30.1

Non-authoritative answer:
gmail.com MX preference =3D 40, mail exchanger =3D
alt4.gmail-smtp-in.l.google.com
gmail.com MX preference =3D 10, mail exchanger =3D
alt1.gmail-smtp-in.l.google.com
gmail.com MX preference =3D 5, mail exchanger =3D gmail-smtp-in.l.goo=
gle.com
gmail.com MX preference =3D 30, mail exchanger =3D
alt3.gmail-smtp-in.l.google.com
gmail.com MX preference =3D 20, mail exchanger =3D
alt2.gmail-smtp-in.l.google.com

alt4.gmail-smtp-in.l.google.com internet address =3D 72.14.247.27
alt1.gmail-smtp-in.l.google.com internet address =3D 209.85.129.114
gmail-smtp-in.l.google.com internet address =3D 74.125.79.114
alt3.gmail-smtp-in.l.google.com internet address =3D 209.85.223.14
alt2.gmail-smtp-in.l.google.com internet address =3D 209.85.218.33

Use one of the servers you see here. These are the public SMTP servers
set to RECEIVE email from anyone. No authority required.

What _IS_ required is a valid recipient.

The output of the nslookup command can also be seen by using getmxrr() in P=
HP.

Look at the user notes on http://docs.php.net/getmxrr for versions of
getmxrr() for versions of PHP on windows which didn't have this
function.

At a fundamental level, this is how email is sent. You normally send
it to a server you are allowed to send to (a relay). This normally
requires some sort of security (not always - but may require you to
POP3 login to your mailbox). You send the mail. The local server
receives it. By using the domain of the recipient the server finds
where to send it. The recipients server knows nothing about YOUR
server - no authority - but has to accept the message.

Using getmxrr() is bypassing the local relay step and going direct.

Obviously, you have to handle all the errors, retries, etc. But you
can also step through the servers if one is offline or whaterver.



--=20
-----
Richard Quadling
"Standing on the shoulders of some very clever giants!"
EE : http://www.experts-exchange.com/M_248814.html
Zend Certified Engineer : http://zend.com/zce.php?c=3DZEND002498&r=3D213474=
731
ZOPA : http://uk.zopa.com/member/RQuadling

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Re: Re: Need help-Send email

am 15.09.2009 00:49:32 von dmagick

> What _IS_ required is a valid recipient.

What google requires to send an email through their servers is smtp
authentication - none was mentioned in the original post (nor any follow
up suggestions).

If the recipient is invalid, it will bounce back - just like any other
email where you mis-spell a name or any of the other problems that can
happen.

--
Postgresql & php tutorials
http://www.designmagick.com/


--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Re: Re: Need help-Send email

am 15.09.2009 01:20:28 von Nagendra Prasad

--001636c5a86f7a1c48047391eaea
Content-Type: text/plain; charset=ISO-8859-1

Hi Chris,

Thanks for the response. However I have coded the Email code with SMTP
authentication. But the problem is my mail is going to the SPAM not in the
inbox. I remember someone has said that if the code is sending the email and
if its going under SPAM folder then the code is correct but I have to work
on client filter. I don't know how? Can you or anyone help me in this.

Here is the code:


/* Setup your Subject and Message Body */
$subject='Testing PHP Email';
$body='Hi the is nagendra prasd.';

/* Specify your SMTP Server, Port and Valid From Address */
ini_set("SMTP","mail.localroot.200u.com");
ini_set("smtp_port","465");
ini_set("sendmail_from","nagendra802000@gmail.com");

/* Additional Headers */
$headers = "Cc:Real CC Name \r\n";


/* Try to send message and respond if it sends or fails. */
if(mail ('ToPersonsName ', $subject, $body,
$headers )){
echo "

Your Message was sent!

";
}
else{
echo "

Your Message Was Not Sent!

";
}
exit;
?>

--001636c5a86f7a1c48047391eaea--