send mail without passwords - php

Is there any way in php or javascript to send mail without passwords.
I need to send mail without asking for his passwords.
Please help me finding the solution.
Thanks in advance.
EDIT
this the code i tried
<?php
error_reporting(E_ALL);
$to = "person2#gmail.com";
$subject = "Test mail";
$message = "Hello! This is a simple email message.";
$from = "person2#gmail.com";
$headers = "From:" . $from;
mail($to,$subject,$message,$headers) or die("errors");
echo "Mail Sent.";
?>
and it displays errors as o/p and not sending mail

With PHP you can just use the mail() function, this does not require the user to enter his/her password.
The SMTP server can be set in php.ini.

you can refer below link for this
http://www.w3schools.com/php/php_mail.asp
mail() function does not work on localhost so check this on server.

Related

In core php i am try to send mail but mail() function not working?

I am try to send an email but on localhost mail function not working?
$subject = "Test mail";
$message = "Hello! This is a simple email message.";
$from = "123#gmail.com";
$headers = "From:" . $from;
mail($email,$subject,$message,$headers);
echo "Mail has been Sent.";
You need to use mail server for that.
If you are running windows: http://www.hmailserver.com/
mail() is doing its part to get a mail on the way. But it can only do so much ... If there's no local MTA installed, it'll fail. Also: Check the return value of mail().

How can I get my website to send an email to someone from my address upon submit?

websiteI want my website to automatically generate an email to be sent to a customer when they click the submit button.
I have added the following php:
$subject = "Thank You";
$message = "Thank you .........";
$from = "info#mywebsite.com";
$headers = "From:" . $from;
mail($email, $subject, $message, $headers);
The variable $email was defined earlier. Also I have edited my php.ini to include the following:
SMTP = smtp.mywebsite.com
smtp_port = 25
username = info#mywebsite.com
password = password
sendmail_from = info#mywebsites.com
Clearly I have not done enough. What more do I need to do?
This question is duplicate with Sending email with PHP from an SMTP server
PHP mail function has some issue with smtp. (It is not support for smtp user name and password) Use 3rd party mail library like Swift mailer, PHPMailer, etc...

PHP mail script does not send mail

I have this mail script on my page: mail('myadress#server.com', 'New client added by user', 'test message');
but I do not receive anything! (of course I added my real adress). I tried it with 2 different adresses, looked in my spam folder, etc... just nothing. but the script executes just fine.
Is there any log I can view or invoke to see exactly what happened?
thank you for your help!
<?php
$to = "someone#example.com";
$subject = "Test mail";
$message = "Hello! This is a simple email message.";
$from = "someonelse#example.com";
$headers = "From:" . $from;
mail($to,$subject,$message,$headers);
echo "Mail Sent.";
?>
try this it will going to work for u ....
1) Check the return value from the mail() call:
$status = mail(...);
if (!$status) {
die("Mail failed");
}
If this fails, then PHP cannot even get the mail out the front door, and you'll have to figure out why - e.g. are you on a Windows box and haven't configured the mail options in php.ini?
2) Check your mail server's logs. Most Unix/Linux systems have a local mail server (the MTA) which will accept the mail from PHP. If it's misconfigured or having trouble, it may still accept the mail from PHP but then leave the mail to rot in a queue.
Perhaps your server's been placed on spam blackhole lists and it simply cannot deliver mail anywhere, which means you've probably got all of your test mails stuck in an outgoing queue that can't go anywhere.
Had to add the header "from" and use an email adress created on the server.

Hide server when sending email from mail php function

All,
I have the following code:
$to = $friend_email[$x];
$subject = "Subject";
$message = "This is a message";
$from = $your_email;
$headers = "From:" . $from;
mail($to,$subject,$message,$headers);
When the email sends (I'm using Godaddy's hosting service) it says From correctly but then in gmail it says via pxnlhgxxx.prod.xhx3.secureserver.net. Is there anyway to hide the via part or make it say something like website.com? Thanks for the help.
As per the mail() docs, you use the optional 5th parameter for the function and pass in the name of the server you'd like to masquerade as:
mail($to, $subject, $message, $headers, "-f sender#website.com");
If your hosting off godaddy then something like that will happen. You can use your own SMTP server, or use Google free SMTP Server (logging in with your gmail account). Host Gator does the same thing.
You can prevent Google from showing the 'via' notice by DKIM signing your outgoing mail to prove that you genuinely control the domain you're sending e-mail on behalf of.
Its all up to the configuration of the smtp server.

PHP email text to gmail account

Is there some way I can take text (retrieved from a form), and email it to my gmail account? I can also have the user enter their email address, and a subject. Or if not is there a better way to have users send me a message? Thanks.
Use mail function to send email to specific address:
$subject = $_REQUEST['subject'];
$message = $_REQUEST['message'];
mail("your#gmail.com", $subject, $message);
But please don't take $to parameter from form, otherwise your script will be used for spamming.
I recommend that you use PHP Mailer this program will take care of all of the message construction and works well with Gmail. There is also sample code included for Gmail.
Expanding on what Ivan wrote to add users email as sender:
$subject = $_POST['subject'];
$message = $_POST['message'];
$from = $_POST['from'];
// the sender email must be cleaned of mime header injection
$from = preg_replace_all("/[\r\n]+/", '', $from);
mail("your#gmail.com", $subject, $message, "from:$from\n");
This makes it easier to reply. However, you could just append their email address in the message body.

Categories