Is there any way to send mail from a gmail account to someone? And by "from" i mean so that it stores the email in the gmail inbox aswell...?
I've tried using imap, but i'm not sure if that's the correct way? Either way i get this error:
Warning: imap_mail() [function.imap-mail]: "sendmail_from" not set in php.ini or custom "From:" header missing in C:\xampp\htdocs\gmail\index.php on line 12
Any idas how to achieve this?
Thanks!
Try using smtp instead, Gmail will put your email in sent folder for you. All the instructions are provided in the settings page of your gmail account.
http://deepakssn.blogspot.com/2006/06/gmail-php-send-email-using-php-with.html
You could do the same thing email clients do: Send your mail through SMTP and then create a mail in the Sent folder through IMAP.
Related
I am trying to send email from the server but it's not sending it throws an error. In phpinfo() I checked mail function is enabled, what's wrong why mail is not sending if anybody has idea means please tell me,
This is my code,
<?php
$msg = "test cotent";
$send =mail("xxxxx#gmail.com","My subject",$msg);
if($send) echo 'sent!';
else echo $errorMessage = error_get_last()['message'];
?>
Error,
mail(): SMTP server response: 554 5.7.1 : Relay access denied
See the answer, may be it will help you.(Please see the last one)
Relay access denied on sending mail, Other domain outside of network
https://jefferyland.wordpress.com/2013/05/28/essential-exchange-troubleshooting-send-email-via-telnet/
Use PHP MAILER for cross domain mailing that way you can define your ports or if you still want to use mail Function you'll have to set up an email with your hosting eg abc#yourdomain.com else it wont allow you to send. mail function uses default mailer hosting urls
mail() function unable to connect with you SMTP that's why you are getting this problem.
To solve this problem you can use PHP MAILER library which is available in GitHub. Using php mailer you can define SMTP, PORT etc.
Either you can create a web mail in your server (info#example.com) and use it in your code.
Hope it will help you to send mail.
I am developin a web site based in wordpress and we have Easy SMTP plugin configured with an SMTP account.
In adiction, I'm coding a plugin to this site. I need all emails been sended from one account, except the emails sended by my plugin.
Theese emails must have another sender (other smtp account). Both SMTP accounts will be in the same SMTP server.
Is this possible? Can I pass some header to wp_mail function to change the SMTP authentication account for a specific email send?
I don't see any documentation that helps me...
Thanks.
edit:
I know that I can do something like:
$cabeceras .= 'From: Recordatorio <cumples#example.com>' . "\r\n";
But i'm not sure that if this is a good method or if is recomendable doing it.
i'm usig php mailer to send email via SMTP using HTML form, recently this error ocured when i'm trying to send that email:
"SMTP server error: 5.7.1 Mail (id-40257-40235) appears to be unsolicited, please resend with the code sy2ururu appended to email subject and ask to have your sender email whitelisted (the code sy2ururu changes each 24 hours)."
What could it mean? Thank you
The SMTP error 5.7.1 is Unable to Relay so the user who is sending the email does not have permissions to the mail server.
you can check PHP.ini for the key sendmail_from as the default is...
sendmail_from = you#yourdomain
My forum has a problem with sending emails :
i have configured my mail settings as the following :
Mail Type : smtp
SMTP Host : myhost
Port : 587
Username & password : a valid email account on my domain
when i click on forget password to test sending emails i got the following message in error log:
Sender address is not valid for your login. Check your email program settings
I am pretty sure that this account is correct, and i tried to add test mail script to my host with the following code :
<?php
$mail = mail("myEmail", "wahahahahahaahahahahaa","I like spamming your inbox!!!", "From: Myself<your_email#here.com");
if(!$mail){
echo 'mail is not sent!';
} else {
echo 'mail is sent :-)';
}
?>
and it prints
mail is sent :-)
What i am missing here ?
I agree with Eggyal - it sounds like the hosted SMTP server is not allowing mail to be sent from the MAIL FROM address that you are using, with the authentication credentials that you are using.
To confirm this, and to rule-out a problem with the way that your application is trying to send the message - you might want to try sending a message through this SMTP server using a standard mail client (such as Thunderbird or Outlook), and using the same MAIL FROM address and authentication credentials that your application is using. If this fails with the same error, then you've confirmed that the hosted SMTP server is not allowing mail to be sent from the MAIL FROM address that you are using, with the authentication credentials that you are using.
Problem Solved.
I added my gmail on webmaster email, i changed it to domain email user then the problem is solved
I know about the mail function in php:
mail ($to, $subject, $msg_body,$headers);
But since I cannot access my host's php.ini file, I've been provided with the following details:
SMTP host: mailout.host.com
Port: 25 SMTP
Username: email#domainname.com
SMTP Password: not required
Authentication: Disabled
Encryption: Disabled
How can I use these details to send out emails?
EDIT: I used example pointed by Blender (below) and it seems to work fine for all emails except gmail. Any idea why? Is it to do with Fully Qualified Address?
PHPMailer is a very well known and widely used alternative
Check out the SMTP mail example
You can use SwiftMailer (http://swiftmailer.org/) to send out emails through any email account you can login to, including gmail. It's very robust, but does have a bug where it uses a lot of memory for emails that have a lot of html in them.