How to send email from wamp/xampp localhost?
I have written the following simple code to send message.
I have already edited php.ini,sendmail.ini configuration files but no use,I can't receive email.I want to send message to any gmail address.I can sent email to my domain mail when this piece of code is uploaded via filezilla to my domain, but when I am giving to address as any gmail id, the code is not working.
<?php
$to = "bytecookiestest#gmail.com";
$subject = "My subject";
$txt = "Hello world!";
$headers = "From: swetha851991#gmail.com";
$s=mail($to,$subject,$txt,$headers);
if($s)
echo "success";
else
echo "failure";
?>
It's most likely a problem with the from-header you're sending. You're using your own Gmail-address to send mails from, but that also means you have to use the Google SMTP server. The credentials of swetha851991#gmail.com are the credentials you have to use to authenticate with the SMTP server. It'll otherwise be marked as spam.
Another option is to set the from-address to an address from the domain you're sending it from. If you domain is example.com, you can set the from-address to anything#example.com.
Related
i am using php code to send emails to gmail or yahoo ids. i am using a 3rd party mail server to send my emails. my php code works and i can receive the content in my gmail inbox. but where do i save my sent emails ?? who gives me an inbox for all my received / sent emails. suggest me a Name ?
function helloEmail()
{
$from = new Email(null, "test#example.com");
$subject = "Hello World from the SendGrid PHP Library";
$to = new Email(null, "test#example.com");
$content = new Content("text/plain", "some text here");
$mail = new Mail($from, $subject, $to, $content);
$to = new Email(null, "test2#example.com");
$mail->personalization[0]->addTo($to);
//echo json_encode($mail, JSON_PRETTY_PRINT), "\n";
return $mail;
}
There is no inbox for your sent mails. You can send an e-mail using any e-mail address you choose, even if it belongs to someone else or doesn't exist.
For your received e-mail inbox, you'll have to make one yourself via any third party e-mail service such as Gmail or Hotmail, or via your web hosting platform using your own domain name if they provide e-mail services.
To save your sent e-mails you can opt to save them in a database.
i am new to php and web development. i am trying to confirm user,s email on signup by sending confirmation message on their email. But it is not working is the problem with my using localhost as a server or there is some other problem? here is my code
{
$to = $_POST['email'];
$com_code = md5(uniqid(rand()));
$subject = "Confirmation from OnlineShopping to $_POST['username']";
$header = "OnlineShopping: Confirmation from OnlineShopping";
$message = "Please click the link below to verify and activate your account. rn";
$message .= "http://www.yourname.com/confirm.php?passkey=$com_code";
$sentmail = mail($to,$subject,$message,$header);
if($sentmail)
{
echo "Your Confirmation link Has Been Sent To Your Email Address.";
}
else
{
echo "Cannot send Confirmation link to your e-mail address";
}
}
my if($sentmail) condition is coming true and i am getting message that your confirmation link has been sent to your email address but i am not receiving any email in my inbox
Nowadays, ISPs usually block any smtp activity, you need a proper mail server. Easiest is to use the gmail smtp server to send mail, just to get you going.
There are plenty of ways to do that, just search "gmail smtp php" and you'll get a bunch of articles.
You need a host to send email with php. I recomend you to use .tk For a free domain and hostinger for free hosting. So you can use this function and test your stuff.
But you can also try changing the php.ini file. http://www.php.net/manual/en/mail.configuration.php
I have noticed that some mails come with the from address like :
Adam Mannet via www.findyourfriend.com.
What headers do I need to pass to the native PHP mail() function to accomplish this when sending e-mail?
I think the via tag is added by the mail server when somebody uses an external (from his domain) smtp server.
Per example,
my email is iceduck#iceduck.net but I send email via Gmail's smtp, you will see From iceduck#iceduck.net via Gmail.com.
If you want to make the via appear then you'll have to send your mail through the smtp server you want to appear in the via.
You can check out this link : http://email.about.com/od/emailprogrammingtips/qt/PHP_Email_SMTP_Authentication.htm
I don't think the solution is in the header.
Best
You should check PHP mail documentation. There is a description how to modify 'From' header. You should use additional_headers to change that header information and include 'friendly name' beside your e-mail address.
<?php
// The message
$message = "Message content";
$headers = 'From: User Name <user#example.com>';
// Send
mail('test#example.com', 'My Subject', $message, $headers);
?>
This should make your from address look like: 'User Name via www.example.com'
1, I tried to send e-mail in PHP to my Facebook group email, but these updates, doesn't appear. If I send the e-mail from my yahoo mail, it posted instantly. What kind of information should I add to the mail header?
2, Is is possible to add images as attachments?
My current mail sender code is:
<?php
$to = "mygroup#groups.facebook.com";
$subject = "Test mail";
$message = "Hello! This is a simple email message.";
$from = "me#yahoo.com";
$headers = "From:" . $from;
mail($to,$subject,$message,$headers);
echo "Mail Sent.";
?>
Does the email need to come from "me#yahoo.com"? Because Yahoo mail uses SPF, which Facebook can use to verify that your email didn't actually come from there, and discard your email as a spoofing attempt.
If the email needs to come from me#yahoo.com, you'll need to connect to Yahoo mail through SMTP, and pass your username and password through, and legitimately send your email from there.
As for image attachments, it's possible.
EDIT: As per the lovely DaveRandom's comment, the following PHP packages should make your job MUCH easier: PHPMailer or SwiftMailer
This question should have a simple, simple answer, but I just can't seem to get it working. Here's the scenario:
I created a php page -> this one: http://adianl.ca/pages/member_application.php. Once the form is completed, it proceeds to http://adianl.ca/pages/member_application_action.php, puts the data into a MySQL db, & thanks the user for their interest. Anyway, the form works perfectly, except for one little thing: whenever someone fills out that form, I want an email to be sent to sbeattie#adianl.ca, informing them that the form was filled out, & the email would include the form components. The problem is, I can NOT get an email to be sent to that address, or any address truth be told. Having a php page send an email should be a simple thing to do, but it's really baffling me.
Can anyone help me with this? This particular problem has been troubling me since yesterday, & if anyone can help me with this...man, thank you soooooo much.
JP
$mail->IsSMTP(); // telling the class to use SMTP
$mail->Host = "mail.adianl.ca"; // SMTP server $mail->From = "webadmin#adianl.ca";
$mail->FromName = "Web Administration [ADIANL]";
$mail->AddAddress("sbeattie#adianl.ca");
$mail->AddCC("justinwparsons#gmail.com"); the #messageBody variable is just a string
If you want to have the email sent using the server's sendmail client, you can use mail.
If you want it to use another mail server, there are extensions to connect to an SMTP server. I use PHPMailer.
If mail doesn't work, it could be that the server is not set up to send email, or it could be that the mail server is rejecting emails sent from php, amongst other reasons.
this code can also be used to email in php so have a look, you can find many more examples of emailing in php look around
?php
$to = "recipient#example.com";
$subject = "Hi!";
$body = "Hi,\n\nHow are you?";
if (mail($to, $subject, $body)) {
echo("<p>Message successfully sent!</p>");
} else {
echo("<p>Message delivery failed...</p>");
}